Wednesday, November 14, 2012

Selenium WebDriver with Ruby in Ubuntu

The other day I blogged about using Seleinum Webdriver with Python. Today I'm looking at creating the same test using Ruby and WebDriver.

I'm going to assume that you have Ruby installed. I use and recommend using RVM to manage your rubies and your gems, but that is personal preference. Once you have RVM, and Ruby 1.9.3 set up, I also recommend creating a gemset for use with Selenium WebDriver. I created one called 'webdriver' with rvm gemset create webdriver. Once this is done simply execute gem install selenium-webdriver to get WebDriver installed. I also am going to be using the 'test-unit' gem in this example so go ahead and gem install test-unit as well.

Once all that is done, we are ready to create our test. Create a file called gmail_test.rb and fire it up in your favorite text editor (I think Sublime Text 2 is simply sublime, personally). This test will assert on the page title, and then log into Gmail, just like the Python and C# examples I gave a few days ago.

Now, for the code:

When this file is run you should receive the following output:

Enjoy, and happy coding!

No comments:

Post a Comment