量角器未知错误,从DOM中删除属性 [英] protractor unknown error, removing attribute from DOM
本文介绍了量角器未知错误,从DOM中删除属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< input type =textname =rptdateinput-date placeholder =DD-MM-YYYYdata-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元素传递到脚本中:
var elm = element(by.name(rptdate));
browser.executeScript('arguments [0] .removeAttribute(input-date);',elm.getWebElement());
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.
解决方案
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());
这篇关于量角器未知错误,从DOM中删除属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文