我正在尝试使用量角器单击一个元素,但低于异常
(node:9208) UnhandledPromiseRejectionWarning: ElementNotVisibleError: element not interactable
(Session info: chrome=69.0.3497.92)
(Driver info: chromedriver=2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5),platform=Windows NT 6.1.7601 SP1 x86_64)
at Object.checkLegacyResponse (........\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (........\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (........\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)Error
at ElementArrayFinder.applyAction_ (........\node_modules\protractor\built\element.js:459:27)
at ElementArrayFinder.(anonymous function).args [as click] (........\node_modules\protractor\built\element.js:91:29)
at ElementFinder.(anonymous function).args [as click] (........\node_modules\protractor\built\element.js:831:22)
at selenMethods.clickElement (........\folders\utils\SelenMethods.js:49:26)
at ........\folders\pages\homePage.js:28:29
at process._tickCallback (internal/process/next_tick.js:68:7)
下面是HTML代码段
<a href="#inviteUser" id="menuBtnAdduser" class="list-group-item list-group-child-item close-menu-item list-item-heading ng-scope" translate="templates.usersTable.addUser" xpath="1"><span class="ng-scope">Invite new user</span></a>
下面是单击该元素的量角器代码
var EC = protractor.ExpectedConditions;
browser.wait(EC.elementToBeClickable(elemen), 4000);
element(by.xpath("//a[@id='menuBtnAdduser']/span[contains(text(),'Invite new user')]"));
答案 0 :(得分:0)
要单击所需元素,可以使用以下解决方案:
var EC = protractor.ExpectedConditions;
browser.wait(EC.elementToBeClickable(elemen), 4000);
element(by.xpath("//a[@class='list-group-item list-group-child-item close-menu-item list-item-heading ng-scope' and @id='menuBtnAdduser']/span[@class='ng-scope' and contains(.,'Invite new user')]"));
答案 1 :(得分:0)
尝试使用Href单击:
element(by.cssContainingText('[href*="#inviteUser"]', 'Invite new user'))