1

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

Ruby:

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

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

Any workarounds for this?

timothyjc
  • 2,188
  • 3
  • 29
  • 54

3 Answers3

1

Check the DOM to see if it is within a frame, or some container that is causing problems. If you cannot access the radio button by value you can reference it by something else, like index. Find the radio button's container, and reference it by the Nth index. So if your button is the second button in table 12 of table 1 you can hone it down like this:

BROWSER.table(:index, 1).table(:index, 12).radio(:index, 2)

Or if it's the 2nd radio button on the page (always) then...

BROWSER.radio(:index, 2)

You can also reference a radio button by other things:

BROWSER.radio(:value, '3G')
BROWSER.radio(:name, 'network')
BROWSER.radio(:id, 'isc_1HV')

For further help I'd need to know if you can reference other element in the same container on that page. For info on how you can reference an element, see here: HTML elements supported by Watir

And if you get totally stuck, you'll need xpath. But this should be a last resort, frankly.

pjd
  • 1,163
  • 8
  • 17
kinofrost
  • 768
  • 6
  • 16
0

Could be in a frame, possibly. The error message should point in the right direction.

orde
  • 1
0

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!

Community
  • 1
  • 1
kinofrost
  • 768
  • 6
  • 16