- Download the Ruby Installer – The Ruby Installer is currently available only for the Windows platform.
- Install the Ruby Installer by double slicking on the .exe file. A new Ruby folder is created in your C drive C:\Ruby200-x64\
- Download Development Kit and Unzip the Development Kit zip file
- Open command-line and go to unzipperd folder
- Execute the below commands from command line C:\Ruby200-x64\bin>gem install selenium-webdriver-2.35.0.gem
ruby dk.rb init
ruby dk.rb install
gem install rdiscount --platform=ruby
- Download the selenium-client to C:\Ruby200-x64\bin.
- Execute the below command
C:\Ruby200-x64\bin>gem install selenium-webdriver-2.35.0.gem
- Open a text editor and copy the following code and save the file as googlesearch.rb under your test script folder in this example D:\Personal\Ruby\Selenium
require 'rubygems'
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :firefox
driver.get "http://google.com"
element = driver.find_element :name => "q"
element.send_keys "Cheese!"
element.submit
puts "Page title is #{driver.title}"
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
wait.until { driver.title.downcase.start_with? "cheese!" }
puts "Page title is #{driver.title}"
driver.quit
- Run googlesearch.rb file as shown below
D:\Personal\Ruby\Selenium>ruby googlesearch.rb
0 Comments