量角器未知错误,从 DOM 中删除属性 [英] protractor unknown error, removing attribute from DOM

查看:19
本文介绍了量角器未知错误,从 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 中删除属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆