Created
July 29, 2009 06:52
-
-
Save hugs/157903 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Environment: | |
| # * Mac OS X: 10.4.11 | |
| # * Firefox: 3.5.1 | |
| # * Java: "1.5.0_19" (build 1.5.0_19-b02-306) | |
| # * Ruby: 1.8.6 (2007-03-13 patchlevel 0) [universal-darwin8.0] | |
| # * Selenium RC: 1.0.1 | |
| # * selenium-client gem: 1.2.16 | |
| # Terminal #1: | |
| # ------------ | |
| ... | |
| $ cd ~/selenium/selenium-remote-control-1.0.1/selenium-server-1.0.1 | |
| $ java -jar selenium-server.jar | |
| # Terminal #2: | |
| # ------------ | |
| $ cd ~/selenium | |
| # Basic 'hello google' test taken from: | |
| # http://github.com/ph7/selenium-client/blob/2a464f87b061d7eec7a5cdf66a3345456ecb0121/README.markdown | |
| $ cat << 'EOF' >> hello-google.rb | |
| #!/usr/bin/env ruby | |
| # | |
| # Sample Ruby script using the Selenium client API | |
| # | |
| require "rubygems" | |
| gem "selenium-client", ">=1.2.16" | |
| require "selenium/client" | |
| begin | |
| @browser = Selenium::Client::Driver.new \ | |
| :host => "localhost", | |
| :port => 4444, | |
| :browser => "*firefox", | |
| :url => "http://www.google.com", | |
| :timeout_in_second => 60 | |
| @browser.start_new_browser_session | |
| @browser.open "/" | |
| @browser.type "q", "Selenium seleniumhq.org" | |
| @browser.click "btnG", :wait_for => :page | |
| puts @browser.text?("seleniumhq.org") | |
| ensure | |
| @browser.close_current_browser_session | |
| end | |
| EOF | |
| $ ruby hello-google.rb | |
| true | |
| $ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment