user3763753
user3763753

Reputation: 11

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

Upvotes: 1

Views: 5538

Answers (1)

Carldmitch
Carldmitch

Reputation: 409

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

Upvotes: 2

Related Questions