gpt4 book ai didi

watir - 如何在 watir 中获取元素的 id 或名称?

转载 作者:行者123 更新时间:2023-12-01 00:02:38 25 4
gpt4 key购买 nike

Watir 可以在页面上找到一段文字:

<span id="i1" name="n1>Some Text</span>

e.text.include?("Some Text")

但是,当我只知道“Some Text”时,如何获得跨度的名称或 ID
e.text.findInPage("Some Text").parentElement.id (should be "i1")
e.text.findInPage("Some Text").parentElement.name (should be "n1");

像这样的东西存在于watir?

最佳答案

browser.span(:text => "Some Text").id
=> "i1"

browser.span(:text => "Some Text").name
=> "n1"

在 Windows、Ruby 1.8.6、Watir 1.6.5、Internet Explorer 驱动程序上测试。

关于watir - 如何在 watir 中获取元素的 id 或名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2718093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com