JavaScud | Forum | JIRA | Blog |
  Dashboard > Selenium 中文 > ... > Selenium chinese translation road map > Selenium Remote Control - Ruby
  Selenium 中文 Log In View a printable version of the current page.  
  Selenium Remote Control - Ruby
Added by Tin Steeler, last edited by Tin Steeler on Nov 16, 2006
Labels: 
(None)

Selenium Remote Control: Using the Ruby Client Driver

RDoc reference is available

First, make sure you've already started the Selenium Server separately in another process. The Selenium Server should remain up and running throughout this process; you shouldn't need to start/stop it each time you use the Client Driver. (Though, of course, if you need to start and stop the server, you certainly can, just by automatically starting it from the command line.)

To use the Ruby Client Driver, just "require" or "load" selenium.rb in your Ruby script, and create a new Selenium::SeleneseInterpreter object. You'll need to give it the hostname and port of the Selenium Server, the browser string to use with "getNewBrowserSession", and the base URL at which we'll start testing. When you're ready to begin, run the "start" method on your SeleneseInterpreter object; when it's time to close the browser, use the "stop" method.

The SeleneseInterpreter object is full of handy methods that handle your Selenium Commands. If one of them has an error (or if an "assert" command fails) the method will raise a SeleniumCommandError with a handy error message, which you can wrap up in a "rescue" block if you like.

If you get tired of typing "@selenium" in front of all of your commands, you can also mixin the SeleniumHelper module, which will automatically pass all calls to missing methods to the @selenium object. You still need to define a @selenium object yourself, and start/stop it normally.

While we recommend that you use the Ruby Client Driver together with Ruby's Test::Unit unit testing framework, Test::Unit is not required; you can use the Ruby Client Driver with any program whatsoever to automate tasks in your browser.

Examples: selenium_example.rb, selenium_real_deal.rb.

Site running on a free Atlassian Confluence Open Source Project License granted to WebWork China. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.3 Build:#808 May 29, 2007) - Bug/feature request - Contact Administrators