我正在使用量角器,并且正在做中继器,首先我得到了文本,然后我试图单击该元素,但是我遇到了错误
c
这是代码
[14:40:00] E/launcher - roleSelected.element is not a function
[14:40:00] E/launcher - TypeError: roleSelected.element is not a function
at role.element.getText.then (/Users/jburquez/akamai/ConsoleUI/tests/e2e/console_bdd/steps/manage_agents_steps.js:41:31)
at elementArrayFinder_.then (/Users/jburquez/akamai/ConsoleUI/node_modules/protractor/built/element.js:804:32)
at ManagedPromise.invokeCallback_ (/Users/jburquez/akamai/ConsoleUI/node_modules/selenium-webdriver/lib/promise.js:1376:14)
at TaskQueue.execute_ (/Users/jburquez/akamai/ConsoleUI/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/Users/jburquez/akamai/ConsoleUI/node_modules/selenium-webdriver/lib/promise.js:3067:27)
at asyncRun (/Users/jburquez/akamai/ConsoleUI/node_modules/selenium-webdriver/lib/promise.js:2927:27)
at /Users/jburquez/akamai/ConsoleUI/node_modules/selenium-webdriver/lib/promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:68:7)
所以不确定在这种情况下我该怎么办,希望您能提供帮助!
答案 0 :(得分:0)
roleSelected
是一个字符串,您正在尝试将另一个Web元素循环到文本。
var agentRoles = element.all(by.repeater('ctrl.roles'));
agentRoles.each((role) => {
return role.element(by.xpath(".//div[@class='md-whiteframe-1dp outset inset']/md-checkbox/div[2]/span")).getText()
.then((roleSelected) => {
if(agentRole == roleSelected){
return agentRole.element(by.xpath(".//div[@class='md-whiteframe-1dp outset inset']/md-checkbox/div")).click().isPresent();
}
});
});
希望以上脚本对您有帮助