gpt4 book ai didi

Ruby Watir 单选框

转载 作者:数据小太阳 更新时间:2023-10-29 08:35:34 25 4
gpt4 key购买 nike

我正在尝试使用 .set 在 radio 控件上设置复选框?选项。它返回 false 但我无法设置复选框。

<div class="">
<input name="radiostorage" id="zrs" value="2" type="radio">
<label for="zrs">Zone-redundant storage (ZRS)</label>
</div>

尝试过使用 label(for: 'zrs').set .click .parent.click .parent.set,也尝试直接点击 input ,但没有任何反应,任何线索

TIA

最佳答案

考虑到单选按钮的实现方式,它不会被视为可见。尝试直接设置它会出现异常:

browser.radio(id: 'zrs').set
#=> element located, but timed out after 2 seconds, waiting for #<Watir::Radio: located: true; {:id=>"zrs", :tag_name=>"input", :type=>"radio"}> to be present (Watir::Exception::UnknownObjectException)

您可以点击其关联的标签,而不是直接设置它,这是实际用户会做的:

browser = Watir::Browser.new
browser.goto('https://pricing-calculator.bluekiri.cloud/')
p browser.radio(id: 'zrs').set?
#=> false
browser.label(for: 'zrs').click
p browser.radio(id: 'zrs').set?
#=> true

关于Ruby Watir 单选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46325585/

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