量角器未知错误,从 DOM 中删除属性
我是量角器的新手并试图从 DOM 中删除属性但得到未知错误",我不确定可能是什么问题
Im new to protractor and trying to remove attribute from DOM but getting "unknown error", Im not sure what could be the problem
我有一个带有自定义指令的简单 HTML.我正在尝试删除它以使我的测试用例通过:
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" />
我运行的命令是:
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");');
但他们都没有帮助.
推荐答案
使用 Protractor 定位元素,然后将 Web Element 传递给脚本:
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());
相关文章