Erik A. Hanson's Weblog

SeleniumQuery

Posted: May 23rd, 2010    Tags: Ruby, Selenium, jQuery

I wrote a tiny library to make Selenium testing in Ruby a little easier by helping you easily build a jQuery string that can be executed in the browser during a test.

This:

# this is ruby
jquery = SeleniumQuery.new(selenium)
id = jquery.find("td:nth(5).user:visible").closest("tr").attr!("id")

executes this in the browser:

// this is Javascript
selenium
  .browserbot
  .getCurrentWindow()
  .jQuery(selenium.browserbot.getCurrentWindow().document)
  .find("td:nth(5).user:visible")
  .closest("tr")
  .attr("id");

Check it out here: http://github.com/eahanson/seleniumquery



Leave a Reply



(Comments are moderated to keep out spam. Please be patient.)