未找到 Watir 单选按钮 [英] Watir Radio Button not found

查看:20
本文介绍了未找到 Watir 单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Watir 中设置这个单选按钮,但它没有找到:

I want to set this radio button in Watir but it is not finding it:

HTML:

<input type="RADIO" style="-moz-user-focus: normal;" tabindex="2421" handlenativeevents="false" value="3G" $9a="$9b" $89="isc_RadioItem_3" id="isc_1HV" name="network">

红宝石:

if BROWSER.radio(:value => '3G').exists?
  BROWSER.radio(:value => '3G').set
end

可能是因为我们的代码包含大写的 RADIO?(由 SmartGWT 生成)

Could it be because our code contains uppercase RADIO? (Generated by SmartGWT)

有什么解决方法吗?

推荐答案

另一种选择.如果它没有响应无线电,因为它不是单选按钮(Watir 会理解它),那么您需要找到另一种方法来单击该对象.您可以尝试单击容器以查看它是否有效,但如果无效,则需要使用硬件单击.您可以找到一个硬件点击解决方案作为鸭子拳(它在我的答案之一下:此处).您可以自定义此代码以接受 x 和 y 修饰符,如果您愿意,那么您可以使用 .left_click 来硬件单击任何元素,包括容器.因此,使用指向单选按钮的 x 和 y 修饰符左击 RADIO 容器.这比仅在绝对 x/y 位置上单击硬件要动态得多,但它会将您的鼠标光标从您身上移开并用它来单击屏幕.我希望这会有所帮助!

Another alternative. If it's not responding to radio because it's not a radio button (as Watir would understand it) then you need to find another way to click the object. You can try clicking the container for it to see if that works, but if not then you'll need to use a hardware click. You can find a hardware click solution as a duck punch (it's under one of my answers: here). You can customise this code to accept x and y modifiers, if you like, then you can use .left_click to hardware click any element, including containers. So left_click the RADIO container with x and y modifiers pointing to the radio button. This is slighly more dynamic than just hardware clicking on an absolute x/y position, but it will take your mouse cursor off you and use it to click the screen. I hope this helps!

这篇关于未找到 Watir 单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆