मैं किससे बात नहीं कर सकता हूं, लेकिन मैं स्रोत कोड ढूंढने और इसकी जांच करने में सक्षम था।
दस्तावेज़ों के अनुसार, elm.isPresent()
और elm.isElementPresent()
समकक्ष हैं। उम्मीद है की वो मदद करदे।
Protractor API Docs
सिर्फ शीर्षक की दाईं ओर View code
करने के लिए एक कड़ी है।
browser.isElementPresent (elm);
https://angular.github.io/protractor/#/api?view=webdriver.WebElement.prototype.isElementPresent
/**
* Schedules a command to test if there is at least one descendant of this
* element that matches the given search criteria.
*
* @param {!(webdriver.Locator|webdriver.By.Hash|Function)} locator The
* locator strategy to use when searching for the element.
* @return {!webdriver.promise.Promise.<boolean>} A promise that will be
* resolved with whether an element could be located on the page.
*/
webdriver.WebElement.prototype.isElementPresent = function(locator) {
return this.findElements(locator).then(function(result) {
return !!result.length;
});
};
elm.isPresent();
https://angular.github.io/protractor/#/api?view=ElementFinder.prototype.isPresent
/**
* Determine whether the element is present on the page.
*
* @view
* <span>{{person.name}}</span>
*
* @example
* // Element exists.
* expect(element(by.binding('person.name')).isPresent()).toBe(true);
*
* // Element not present.
* expect(element(by.binding('notPresent')).isPresent()).toBe(false);
*
* @return {ElementFinder} which resolves to whether
* the element is present on the page.
*/
ElementFinder.prototype.isPresent = function() {
return this.parentElementArrayFinder.getWebElements().then(function(arr) {
if (arr.length === 0) {
return false;
}
return arr[0].isEnabled().then(function() {
return true; // is present, whether it is enabled or not
}, function(err) {
if (err.code == webdriver.error.ErrorCode.STALE_ELEMENT_REFERENCE) {
return false;
} else {
throw err;
}
});
}, function(err) {
if (err.code == webdriver.error.ErrorCode.NO_SUCH_ELEMENT) {
return false;
} else {
throw err;
}
});
};
elm.isElementPresent();
https://angular.github.io/protractor/#/api?view=ElementFinder.prototype.isElementPresent
/**
* Same as ElementFinder.isPresent(), except this checks whether the element
* identified by the subLocator is present, rather than the current element
* finder. i.e. `element(by.css('#abc')).element(by.css('#def')).isPresent()` is
* identical to `element(by.css('#abc')).isElementPresent(by.css('#def'))`.
*
* @see ElementFinder.isPresent
*
* @param {webdriver.Locator} subLocator Locator for element to look for.
* @return {ElementFinder} which resolves to whether
* the subelement is present on the page.
*/
ElementFinder.prototype.isElementPresent = function(subLocator) {
if (!subLocator) {
throw new Error('SubLocator is not supplied as a parameter to ' +
'`isElementPresent(subLocator)`. You are probably looking for the ' +
'function `isPresent()`.');
}
return this.element(subLocator).isPresent();
};
यही वह उत्तर है जिसे मैं प्राप्त करने की उम्मीद कर रहा था। आपका बहुत बहुत धन्यवाद! मुझे उपस्थिति के इन 3 तरीकों को काफी भ्रमित करने की जांच होती है क्योंकि वास्तव में विधियों के बीच मतभेद हैं और यह स्पष्ट नहीं है कि विधियों का नाम कैसा दिख रहा है, इस पर अंतर क्या है। इसके अलावा, मतभेद सही ढंग से दस्तावेज नहीं हैं। उम्मीद है कि यह जवाब सिर्फ अंतर को भर देगा और भविष्य में दूसरों की मदद करेगा। – alecxe