protractor unknown error, removing attribute from DOM(量角器未知错误,从 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());
这篇关于量角器未知错误,从 DOM 中删除属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:量角器未知错误,从 DOM 中删除属性
基础教程推荐
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
