If you've not had a look at it yet, now's the time! Selenium-Webdriver will allow you to execute web tests using a range of browser easier than before. You can also use your favourite programming or scripting language and a range of other tools to enhance your testing.
As always, I'll be using Ruby on Windows for this demo and assume you have Firefox browser available - let's get going!
1. Install Ruby
To do that either read the blog post here or watch the video on YouTube:
2. Check your Gems
We're going to need the selenium-webdriver gem. To install that, open a CMD window (start > run > 'cmd') and type gem install selenium-webdriver. You can check installed Gems by typing gem list which shows what's available and their version.
3. Start Interactive Ruby (IRB)
For this demo we'll just run commands straight from IRB. Using a CMD window type irb to start IRB.
In IRB type require 'selenium-webdriver' to start a webdriver instance so we can pass it commands to execute.
4. Open the browser!
Yes, we're ready to start using Webdriver. Now type the following to invoke an instance of Firefox with the reference of browser.
browser = Selenium::WebDriver.for(:firefox)
If all is OK then Firefox will open. If you get an 'access' warning, just click OK.
5. Run some tests
Now work through the following commands to run a basic test using Google.
Google will now load in the blank browser instance.
Type: browser.find_element(:name, "q").send_keys("Hello)
This will type 'Hello' in the query text field, but not return it.
Type: browser.find_element(:name, "btnG".click)
We'll now see search results returned.
References for DYOR: