简体   繁体   中英

How to check if element exist in user extension?

I'm in my custom function:

Selenium.prototype.doCheck = function () {

   //do something
}

Within this function, I want to check whether an element exist in DOM, I tried a number of syntax but none of them worked eventually:

[error] Unexpected Exception: TypeError: this.verifyElementPresent is not a function. 
[error] Unexpected Exception: TypeError: this.doVerifyElementPresent is not a function. 
[error] Unexpected Exception: TypeError: this.IsElementPresent is not a function
[error] Unexpected Exception: TypeError: Selenium.IsElementPresent is not a function. 

How can I do this in user-extension.js?

Try this code:

Selenium.prototype.doTypeRepeated = function(locator, text) {
    // All locator-strategies are automatically handled by "findElement"
    var element = this.page().findElement(locator);

    // Create the text to type
    var valueToType = text + text;

    // Replace the element text with the new text
    this.page().replaceText(element, valueToType);
};

(taken from here )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM