protractor unknown error, removing attribute from DOM

放肆的年华 提交于 2019-12-01 08:42:17

问题


Im new to protractor and trying to remove attribute from DOM but getting "unknown error", Im not sure what could be the problem

Im having a simple HTML with a custom directive.I am trying to remove that for my test cases to pass:

<input type="text" name="rptdate" input-date placeholder="DD-MM-YYYY" data-ng-model="newPatReports.reportDate" />

Commands I ran are:

browser.executeScript( 'document.getElementsByName("rptdate").removeAttribute("input-date")' );
browser.driver.findElement(protractor.By.name('rptdate')).removeAttr("input-date");
browser.executeScript('document.querySelector("input[name='rptdate']").removeAttribute("input-date");');

But none of them helped.


回答1:


Locate the element with Protractor and then pass the Web Element into the script:

var elm = element(by.name("rptdate"));

browser.executeScript('arguments[0].removeAttribute("input-date");', elm.getWebElement());


来源:https://stackoverflow.com/questions/34828620/protractor-unknown-error-removing-attribute-from-dom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!