Tips for Selenium Testing Newbies

I recently became very interested in test automation. I had worked with some tools like Selenium IDE (Firefox) or JMeter previously, but not extensively.  Although automation requires some programming experience, I didn’t let myself become intimidated by the challenge.

When my first opportunity to automate testing presented itself I first had to select the right tool and the right language for the job.  After talking with some co-workers, I decided to use Selenium WebDriver with Ruby.

As an aside, I highly recommend Ruby to others because it’s a very simple and logical language.  I recommend beginners check out Ruby in 20 minutes and Code School. Within minutes, you will have everything you need to write automation scripts.

As for Selenium WebDriver, surely the best starting point is the official documentation. The cool part there is that you can choose the language you want to work, and the site shows plenty of examples of how Selenium works with that language.

Those of us on Windows machines should download Ruby and then install Selenium’s GEM.  To do this, after installing Ruby, go to the BIN folder in the Ruby version that you have installed and run the command:

gem install selenium-webdriver

You can use a command like this to install any GEM you need.

My project lead me to a few more tips that I wish I’d known before I got started:

  • Always check for Selenium updates.  See http://selenium.googlecode.com/git/java/CHANGELOG. This will be very helpful to know for example that the latest supported version of Firefox is 28
  • Sometimes “element.click” can malfunction. When this happens, try substituting “element.send_keys: return“
  • Don’t be afraid to trace object properties using the  “text” or “map (&.: text)” properties. These will help you discover if you are actually working with the object you’re assuming you are working with
  • Get used to creating a hierarchy of folders and files so you can use just one file to call the entire set of tests. I usually use “init.rb” to call any other files needed to build my scenarios

Automated testing turned out to be easier to learn than I thought, and now I have a new powerful tool in my toolkit.

Restored from Internet Archive · Capture: Sat, 19 Sep 2015 19:42:03 GMT