【问题标题】:How to write deepCss for input Textbox in protractor?如何在量角器中为输入文本框编写 deepCss?
【发布时间】:2020-01-10 17:35:18
【问题描述】:

我正在尝试在量角器的输入文本框中发送密钥。它位于 shadow-root 中,并且有三个输入文本框。

【问题讨论】:

  • 请点击您问题标签下的edit。然后您应该能够在 ~~~ ~~~ 之间添加 html。如果您的问题与未来访问者的利益不同,请另开一个问题。

标签: html typescript selenium css-selectors protractor


【解决方案1】:

这是您必须运行以返回元素的 javascript。

document.querySelector('tahiti-app').shadowRoot.querySelector('vaadin-text-field').shadowRoot.querySelector("input[aria-labelledby='vaadin-text-field-label-1']")

有关如何使用 shadowroot 元素的详细信息,请参阅this 答案(尽管它不特定于量角器)。

试试下面的代码:

browser.executeScript("document.querySelector(\"tahiti-app\").shadowRoot.querySelector(\"vaadin-text-field\").shadowRoot.querySelector(\"input[aria-labelledby='vaadin-text-field-label-1']\").value=\"1234\";"
).then( function(){
 console.log('Done'); 
});

【讨论】:

  • 评论不用于扩展讨论;这个对话是moved to chat
  • 谢谢@SamuelLiew,我不确定 OP 是否可以加入聊天,因为他没有足够的声誉。如果您不介意,请告诉我链接,该链接提供了如何移动 cmets 进行聊天的信息。
  • 版主创建的聊天室授予之前所有参与者的访问权限。见chat.stackoverflow.com/rooms/info/199216/…
  • 试图检查单选按钮是否已被选中但它不工作。browser.executeScript("document.querySelector(\"tahiti-app\").shadowRoot.querySelector(\"tahiti -groups\").shadowRoot.querySelector(\"vaadin-radio-button[value='plant']\").checked").then(function () { console.log('Plant Radio button已被选中' );
猜你喜欢
  • 2019-06-03
  • 1970-01-01
  • 1970-01-01
  • 2010-09-17
  • 2018-09-08
  • 1970-01-01
  • 1970-01-01
  • 2019-10-12
  • 2018-07-13
相关资源
最近更新 更多