Thursday, April 21, 2011

Getting Selenium Remote Control to work

I was recently tasked with creating a suite of automated functional tests to run against a website in Internet Explorer. I've been using Selenium IDE for other functional tests because of how easy it is to create a baseline script with the record/playback feature, but unfortunately using IDE limits your testing to Firefox since IDE is a Firefox plug-in. So, we must use Selenium Remote Control instead.

Selenium RC allows for flexibility with browsers used, among many other things. Setting up Selenium RC though is more complicated than getting started with IDE, so I thought I'd commit my findings to the Internet - as other posts I had found during my setup process on the subject were inconsistent.

1. PC running Windows (I love Mac's but I'm using a PC for this)
2. Firefox with the Selenium IDE plug-in installed (see Selenium Downloads)
3. Selenium Server downloaded with a correct java version running on your machine. (Java download if needed; & more info if you have trouble)

Step-by-step instructions on setting up Selenium RC:
  1. Create a working directory on your hard drive (ie: C:\Selenium). Tip: Keep it close to the root so you don't have to type long paths in the future.
  2. Copy the Selenium server file to the working directory. Tip: You may want to consider giving this file a shorter name so you don't have to type so much in the future (ie: "selenium-server.jar").
  3. Write 2 different sample tests using Selenium IDE (just to get this set up) and save them to the working directory.
  4. Change the extensions of the sample IDE files to .html
  5. Create an html file called "TestSuite.html" and save it to the working directory. This file should contain a directory of tests in the suite, as illustrated in the image below. Just rename the variables to suit your needs or add more rows as needed.
  6. Create a blank html file called "Results.html" and save it to the working directory. (Selenium RC needs a file, blank or not, with this name to operate)
  7. Open a command prompt in Admin Mode (Start > "cmd" > CTRL+SHIFT+ENTER)
  8. Navigate to the working directory in the command prompt.
  9. Type this command to start: java -jar selenium-server.jar -htmlSuite *iehta "" "C:\Selenium\TestSuite.html" "C:\Selenium\Results.html"
From here the Selenium Server should start up and start running the test suite. It will use the "TestSuite.html" file to navigate to your individual tests. The "*iehta" in this case opens Internet Explorer, but other commands can be used to open other browsers. At the end of the test, a nice report will be saved to "Results.html" for you to review.

Happy automated testing!

Wednesday, April 6, 2011

Best Wishes to Bryan Stow

I just bought a couple of bracelets from Bryan Stow's family. Bryan is the SF Giants fan who was savagely attacked in L.A. at the Dodgers home opener vs the Giants. His family has set up a blog and a donation account to help his family with medical expenses. I wish him a speedy recovery.

Update 4/16/11:
Now there is this site too: