Learning Selenium-Webdriver on Linux w/ Ruby
My first time using Selenium was last year. I installed Selenium IDE, Firefox plugin, it's basically a recording tool and there is no "real" scripting involved. Though once you have recorded a test or test suite you can edit the back end code that is generated. I am on a serious journey to become an EXPERT at QA Test Automation so last night I installed Selenium-Webdriver on my machine. Today I took some time to read about it on the train and this evening I became Dr. Evil!!!!!
Selenium automates browsers and web applications. It has a variety of Tools Selenium-Webdriver, Selenium RC and Selenium IDE. However, for the purpose of this exercise we are going to learn Selenium-Webdriver. Selenium-Webdriver seems to be the most interesting. You can run scripts in the following languages: Ruby, Java, Perl, C#, Python, and PHP. For the purpose of the exercise we are using Ruby.
Assumptions for this exercise:
You have Ubuntu Linux installed and have a basic understanding of it
You have Ruby installed and have a basic understanding of it
You have Firefox Installed and have a basic understanding of it
Go to your Ubuntu Terminal and type:
$sudo gem install selenium-webdriver
selenium-webdriver should be successfully installed with rubygems
From your Ubuntu Linux Terminal command line prompt:
irb - this will launch interactive ruby
require 'rubygems' - this loads rubygems
require 'selenium-webdriver' - this loads the webdriver for use
driver = Selenium::WebDriver.for :firefox - this helps load firefox you will see JSON message. After the JSON message is received a blank firefox window will open up
driver.get "http://hisandhernews.com" - This will open up hisandhernews.com website
NOTE: Each time you enter you will see "true" which means that Ruby has evaluated the Object you have entered.
aq-kiss@aq-kiss-Dell-DXP061:~$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'selenium-webdriver'
=> true
irb(main):003:0> driver = Selenium::WebDriver.for :firefox
Warning: multi_json is using default ok_json engine. Suggested action: require and load an appropriate JSON library.
=> #<Selenium::WebDriver::Driver:0x..fb7221548 browser=:firefox>
irb(main):004:0> driver.get "http://hisandhernews.com"
=> ""
irb(main):005:0>
HOLY COW You just Learned how to Script in Selenium with Ruby in a Ubuntu Linux Environment!!!!!
http://seleniumhq.org/projects/webdriver/
http://seleniumhq.org/download/
http://rubygems.org/gems/selenium-webdriver
http://rubydoc.info/gems/multi_json/1.0.4/MultiJson