简体   繁体   English

使用Watir-Webdriver选择单选按钮

[英]Using Watir-Webdriver to select radio button

I am trying to automate a survey and so far so good until I came to radio buttons which I assumed would be easy but I can't get them right. 我正在尝试使调查自动化,到目前为止效果很好,直到我接触到单选按钮为止,我认为这很容易,但是我做对了。

The HTML code is this: HTML代码是这样的:

<span class="radioButtonHolder">

<span class="radioBranded" style="background-position: 0px -1px;"></span>
<input id="A.1" class="customCtrlLarge" type="radio" value="1" name="A"></input>

With Watir-Webdriver I tried: 使用Watir-Webdriver,我尝试:

browser.radio(:name => 'A', :value => '1').click

This hasn't worked. 这没有用。 I have also tried: 我也尝试过:

browser.radio(:id => 'A.1').click
browser.find_element(:name => 'A', :value => '1').click

I've run into a similar problems on the site I test, in order for the front-end developer to 'stylize' the radio buttons he 'covers' them with a 'span' element. 为了使前端开发人员“风格化”单选按钮,他使用“ span”元素“覆盖”它们,在我测试的网站上也遇到了类似的问题。 Making the 'actual' radio element unclickable. 使“实际”单选元素不可点击。 To get around this I 'click' on the 'span' element, which sets the radio selection. 为了解决这个问题,我“单击”“ span”元素,它设置了单选。

I'm assuming you already tried to 'set' the radio button? 我假设您已经尝试“设置”单选按钮?

browser.radio(:name => 'A', :value => '1').set

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM