Wunderbread
Wunderbread

Reputation: 1070

Selenium Webdriver - Ruby Unsupported Command

Using Selenium IDE, I have exported a basic test which logs into an account, mouses over a drop-down, and locates the log out button. The test then ends.

The issue that I am seeing is that when the test is exported within ruby/test::unit/web driver that my previous command waitForPopUp is not supported and returns

# ERROR: Caught exception [ERROR: Unsupported command [waitForPopUp | _self | 30000]]

I need the ruby translation to navigate to that mouseover because otherwise the test will time out and return an error. Also, if I run into this issue again if you can link me to a list of ruby webdriver commands.

Upvotes: 1

Views: 1176

Answers (1)

bbbco
bbbco

Reputation: 1540

When exporting test cases created using Selenium IDE to languages like Ruby, there are some commands that are not perfectly converted. waitForPopUp happens to be one of these commands. Instead, you will need to find the line in the code that was unable to be converted and write a supported command to do the same thing.

You probably want to use something like this (untested code!):

# This code defines the method
def wait_for_and_switch_to_new_popup(timeout = 30) # seconds
  Selenium::WebDriver::Wait.new(:timeout => timeout,:message => "Failed to find popup within #{timeout} seconds!").until do
    @driver.window_handle != @driver.window_handles.last
  end
  @driver.switch_to.window(@driver.window_handles.last)
end 

...

# This calls the method to wait for and switch to the new popup.
# Use this inside your code to tell the browser to switch to the new popup
wait_for_and_switch_to_new_popup

To learn more about the Ruby bindings (the DSL) for Selenium WebDriver, you can learn about them at the official Wiki page: http://code.google.com/p/selenium/wiki/RubyBindings

Upvotes: 4

Related Questions