简体   繁体   中英

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:

<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:

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. Making the 'actual' radio element unclickable. To get around this I 'click' on the 'span' element, which sets the radio selection.

I'm assuming you already tried to 'set' the radio button?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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