Selenium::WebDriver::Error::MoveTargetOutOfBoundsError and jQueryUI Radio Buttons

- - posted in Uncategorized

I was getting Selenium::WebDriver::Error::MoveTargetOutOfBoundsError when using jQueryUI’s nice radio buttons. The problem is that the actual radio button html element is hidden via css, so Selenium can’t find it.

I updated the web_steps.rb with the following step:

1
2
3
4
5
6
7
8
When /^(?:|I )choose “([^"]*)”$/ do |field|
begin
radio\_button\_label = find(:xpath, “//label[@for='#{field}']“)  
radio\_button\_label.click
rescue Capybara::ElementNotFound
choose(field)
end
end

This assumes that you are tying your labels to the radio buttons appropriately – so that the label itself is actually clickable.