Posted By

noah on 07/01/09


Tagged

javascript js test ruby BDD client TDD selenium unit idiomatic


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


Waiting for events with the Selenium-Client Ruby driver


 / Published in: Ruby
 

URL: http://selenium-client.rubyforge.org

List of commonly used wait_for commands

For convenience, here are direct links to the documentation of the Selenium-Ruby wait_for commands that are most often used. The documentation of WaitFor commands in Selenium Core may also be of interest.

  1. wait_for_condition
  2. wait_for_element
  3. wait_for_field_value
  4. wait_for_frame_to_load
  5. wait_for_no_element
  6. wait_for_no_field_value
  7. wait_for_no_text
  8. wait_for_page
  9. wait_for_page_to_load
  10. wait_for_popup
  11. wait_for_text
Where to find the documentation

More information onwait_for with the Ruby client, including a complete list of the wait_for commands available in the Ruby client, is to be found in the documentation for the Selenium-Client Ruby Gem. As Selenium-Client defines many "idiomatic" Ruby aliases for built-in Selenium methods, it will probably be especially helpful to become familiar with the Selenium Ruby driver command set as well as Selenium-Client's Idiomatic Ruby command set.

It may also be helpful to refer to the documentation for Selenium Core with regard to WaitForCondition and related commands. In general the Selenium Core documentation tends to provide more insight into how commands work, than does the documentation for any of the drivers.

Examples

Below are a couple of examples of using Selenium's wait_for family of commands with the Ruby driver (Selenium-Client).

One item of note is that , within wait_for_condition, one does not need to use this.browserbot.getCurrentWindow() to access the DOM of the AUT

  1. @selenium.wait_for_element "//div[@id='foo']"
  2.  
  3. # if the application under test uses jQuery, then you can do
  4.  
  5. @selenium.wait_for_condition "$('#foo').css('display') == 'block'", 2
  6.  
  7. # otoh if jQuery is not available, use native DOM methods:
  8.  
  9. @selenium.wait_for_condition "document.getElementById('foo').style.display == 'block'", 2
  10.  
  11. # Note that, within wait_for_condition, I did NOT need to use
  12. # this.browserbot.getCurrentWindow().$() and instead I could
  13. # simply refer to $()

Report this snippet  

You need to login to post a comment.