我在我的自定义功能中:
Selenium.prototype.doCheck = function () {
//do something
}
在这个函数中,我想检查一个元素是否存在于DOM中, 我尝试了一些语法,但最终都没有起作用:
[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.
如何在user-extension.js中执行此操作?
答案 0 :(得分:0)
试试这段代码:
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);
};
(摘自here)