使用 Watir,如何使用名称和值选择无线电控件?

发布于 2024-12-13 07:19:05 字数 469 浏览 4 评论 0原文

我在函数中收到名称状态(值),我想设置其中一个单选按钮。

我正在尝试做类似的事情,但不接受

r = $browser.input(:name => number).parent.radio :value => status
r.set

单选按钮的 html 是这样的

<input id="1" type="radio" checked="checked" value="activo" name="b1" onclick="oncheckRadio();" tabindex="7">    
<input id="1" type="radio" value="inactivo" name="b1" onclick="oncheckRadio();" tabindex="8">

I receive in my function the name and the status (value) and with that i want to set one of the radio button.

I'm trying do do something like this but is not accepting

r = $browser.input(:name => number).parent.radio :value => status
r.set

the html of the radio buttons is this

<input id="1" type="radio" checked="checked" value="activo" name="b1" onclick="oncheckRadio();" tabindex="7">    
<input id="1" type="radio" value="inactivo" name="b1" onclick="oncheckRadio();" tabindex="8">

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

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

发布评论

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

评论(1

盛夏尉蓝 2024-12-20 07:19:05

我并不完全遵循此业务逻辑,但这里有一些为您提供的溯因推理(猜测)

def set_radio_by_name_and_status(name, status)
    $browser.radio(:name => name, :status => status).set
end

但是,两个单选按钮都被命名为“b1”,因此按名称设置似乎有点多余。我想您指的是单选按钮的名称和状态。

I'm not entirely following the business logic of this, but here's some abductive reasoning for you (a guess)

def set_radio_by_name_and_status(name, status)
    $browser.radio(:name => name, :status => status).set
end

However, both radio buttons are named "b1" so setting by name seems a little redundant. I presume you meant the name and status of the radio button.

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