Home

aidylewis edited this page Sep 14, 2010 · 25 revisions
Clone this wiki locally

rquery extends selenium-webdriver by injecting jQuery into the browser, to expose the jQuery traversal API (including CSS 3 and jQuery’s custom extensions) to Ruby.

Getting Started on Windows:

  • Install the 1.8.6 ruby installer (check the “add ruby executables to PATH” option when installing)
  • Install the devkit (just unpack the 7z file over c:\ruby)
  • gem install selenium-webdriver
  • gem install win32-process
  • Download the rquery source
  • open a command prompt and type: ‘set selenium_driver=ie’
  • cd to [rquery directory]\bin’
  • type ‘ruby rquery_console’
  • type ‘cheat’, and there are your methods’

These pages should help you

selectors
traversing

Interactive Example Session

visit “www.google.com”
jquery(“input”).eq(0).parent.html
jquery(“input.lst”).val(“aidy-lewis”)
jquery(“input.lsb”).click
jquery(“a:contains(‘Aidy Lewis, Cucumber, Celerity, & FireWatir – 09/03/2009’):first”).click

Tips and Tricks

  • To inject jQuery into your page, drag the jQuerify link into you bookmarks from here and then you can debug from your script console
  • Finding ID’s with CSS selectors (as described here) requires the use of 4 backslashes, e.g. to find the checkbox “user.name” you can either use jquery(“#user\\\\.receiveInfo”).click or the more readable jquery(“[id=user.receiveInfo]”).click
  • To tick a checkbox: jquery(“input[name=‘agreement’]”).not(“:checked”).click
  • The browser will implicitly close after test run but you can keep the browser open by setting an environment variable to: ‘set keep_browser_open=true’