如何使用 Watir 访问具有自定义属性的元素?

发布于 2024-08-05 05:52:10 字数 189 浏览 2 评论 0原文

我的 HTML 看起来像这样:

<input custom_attribute="so cool" type="text" />

我想使用 Watir 在其中输入文本。

I have HTML that looks like this:

<input custom_attribute="so cool" type="text" />

I would like to enter text in it using Watir.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无人接听 2024-08-12 05:52:10

Filipin 的回答不适用于我的 watir-webdriver 工作。

不过,我确实找到了一种使用 css 选择器来完成这项工作的方法。

browser.element(:css, "input[custom_attribute='so cool']").send_keys("the coolest")

Filipin's answer did not work for my job with watir-webdriver.

I did, however, find a way to do the job with css selectors.

browser.element(:css, "input[custom_attribute='so cool']").send_keys("the coolest")
樱花坊 2024-08-12 05:52:10
browser.text_field(:xpath , "//input[@custom_attribute='so cool']/").set("even more cool")

来源:

browser.text_field(:xpath , "//input[@custom_attribute='so cool']/").set("even more cool")

Sources:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文