1
我已经写了下面的代码来检查定位器类型,并根据元素是否可见,我返回元素。我使用适当的值在调用类型(locatorType,value,text)方法上收到错误。量角器:等待一个元素,然后执行动作
this.type = function(locatorType,value,text){
this.getElement(locatorType,value).sendKeys(text)
};
this.getElement = function(locatorType,value){
if(locatorType=='model'){
console.log(locatorType)
console.log(value)
return this.waiterFunc(element(by.model(value)));
}
else if(locatorType=='xPath'){
return this.waiterFunc(element(by.xPath(value)));
}
else if(locatorType=='buttonText'){
return this.waiterFunc(element(by.buttonText(value)));
}
};
this.waiterFunc = function(element){
console.log('In waiterfunc')
//console.log(element.getText())
browser.wait(function() {
return this.isVisible(element).then(function(){
return element;
})
})
};
this.isVisible = function(element){
return EC.visibilityOf(element);
};
的webdriver是无法找到的元素,并在其上执行的操作。请提出我错在哪里。
它仍然失败,错误:失败: 失败:this.getElement( ...)。sendKeys不是函数 – Abhinav
而在运行代码时,我可以看到它并不是等待元素加载。 – Abhinav
@Abhinav好了,更新了。请检查。 – alecxe