本文介紹了量角器未知錯誤,從 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 中刪除屬性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!