gpt4 book ai didi

html - ruby /瓦提尔 : go to next button of the same class

转载 作者:太空宇宙 更新时间:2023-11-03 17:35:23 24 4
gpt4 key购买 nike

我有一个表格,所有的按钮都是这样的:

<button class="button_class btn" type="button">

我想使用 Watir/Ruby 单击所有这些。这是点击第一个的代码:

browser.button(:class => 'button_class btn').click

我该怎么做才能转到下一个并单击它?

谢谢

最佳答案

如果您只想点击第二个按钮(而不是点击每个按钮),您可以使用 :index 定位器。

browser.button(:class => 'button_class btn', :index => 1).click

注意:

  • :index 是匹配元素的位置 - 即:index 1 是第二个具有“button_class btn”类的按钮。
  • :index 是从 0 开始的 - 即 0 是第一个匹配元素,1 是第二个匹配元素,等等。

关于html - ruby /瓦提尔 : go to next button of the same class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18640538/

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