November 13, 2009, 10:35 am
I tried to run tests in parallel against IE using the selenium grid for a few days before I found this important message on the selenium grid FAQ.

If you try to run multiple selenium remote controls for IE on one machine it will work for a while. Your test will execute without any problems, but then you start getting sporadic error messages from IE. I assumed that the xpath expressions I was using for the tests in Firefox were throwing errors in IE. I tried different configurations for security settings in IE for a while and then I finally found out that it was a memory sharing issue that prevents the selenium remote from launching more than one IE instance. For now I am just requesting more VMs to run a single IE remote on each. I use ruby with deep test to run test in parallel on the grid. I configure deep test to run 6 tests at a time, so I would only need 6 VMs for IE to run.
It puzzling to me that Watin tests run in parallel against IE without any problems on the same machine, but selenium tests cannot. For now I will add more VMs and wait for Selenium Grid 1.2 to fix the IE problem.
October 30, 2009, 1:55 pm
This article will describe how I was able to use the team city rake runner to launch selenium grid tests. I learned a few tricks to get this to work correctly. I first had to learn the makeup of a rspec specktask. Next I needed to understand how to pass in spec options and lastly I needed to write a rake task that would execute in an exact order. I needed to still generate the html report with the rake task so I had to add the formatter path to the rake runner
Setup the report formatter path in your rake runner like you do in your rake file.
See the code below to see how the formatter path is setup in the rake file. You can also see how the formatter path is used by the rake task.
# Make sure we pick up the reporter from the appropriate selenium-client
# install as RSpec runner --require does not discriminate between multiple
# selenium-client gems.
report_formatter_path = `gem which -q "selenium/rspec/reporting/selenium_test_report_formatter"`.chomp
report_formatter_path.gsub! /selenium-client-\d+\.\d+.\d+/, "selenium-client-1.2.7"
Spec::Rake::SpecTask.new("spec:run_in_parallel_report") do |t|
t.spec_files = FileList['./*_spec.rb']
t.deep_test :number_of_workers => 6,
:timeout_in_seconds => 300
t.spec_opts << '--color'
t.spec_opts << "--require 'rubygems,#{report_formatter_path}'"
t.spec_opts << "--format=Selenium::RSpec::SeleniumTestReportFormatter:./tmp/test_report.html"
t.spec_opts << "--format=progress"
t.fail_on_error = false
end
Setup the spec opts in the rake runner.
See the image below. I need to tell team city which formatter to use and where to put the html report. To pass in spec options to the rake runner in team city just put them in the text field labeled RSpec options(SPEC_OPTS): .
My full spec ops string is:
–require ‘/usr/lib/ruby/gems/1.8/gems/selenium-client-1.2.7/lib/selenium/rspec/reporting/selenium_test_report_formatter.rb’ –format=Selenium::RSpec::SeleniumTestReportFormatter:./tmp/test_report.html

Run your rake task.
I made a rake task to take selenium grid environment variables as arguments. If you wanted to run the task above, just add the task name “spec:run_in_parallel_report” in your rake configuration. You don’t need any command line parameters for the spec:run_in_parallel_report task.
October 29, 2009, 2:10 pm
I recently found out why my automated tests run in parallel from my workstation, but then run in sequence from a team city build agent. It all comes down to the rake runner in team city. Team city uses a customized rake runner that extends rspec’s spec task. You get all of the per test reporting, graphing and historical information from team city’s customized rspec reporting. All this is great if you don’t mind running your tests in sequence, but If your using team city to launch automated web test using the selenium grid this is bad news.
I use a rake file to control the execution of my ruby selenium scripts. I modeled it from the ruby example in the selenium grid distribution. What is important to know about the run in parallel rake task is that it is not your normal rake task. It is first a rspec spec task. This is a test runner from rspec that allows you to use a rake task to run specs. Not only is it a spec task, it also has been overridden by deep test, the software package that adds parallelization. Since the spec task is actually deep test’s spec task and not the rspec spec task there are dependencies on what version of rspec deep tests needs. You must run with rspec 1.1.8 so that the spec task that deep test overrides will work correctly.
So what happens when you run your deep test spec task from team city with their rake runner? Deep test cannot launch your tests in parallel because Team City is using their customized spec task. The solution is to use the command line runner to launch your rake task for the selenium grid, then your spec task will have access to the correct rspec gem for deep test to use as a spec runner.
October 15, 2009, 8:56 pm
I have been running test/unit scripts on the grid for a while now and I was trying to remember where I got my test/unit syntax from. I was looking to create a live template to create new test scripts in Rubymine. You actually have to make sure that you create the Selenium Driver object in a specific way or your scripts will not run on the Selenium Grid or they will not run in parallel correctly. Your test class must also always have a setup and tear down, even if you call a method out side of the class to setup the driver.
There are 2 sources of information that you must understand and monitor for updates. First is the Selenium Grid home page. Recently when Firefox 3.5 became available, I needed to update the version of the grid software I was using. The other site is the site for the selenium client gem. You can find documentation here on how to structure your spec and test/unit scripts so that they run on the grid. The gem and the grid are both maintained by the same person. I revisit the sites often to pick up tips on how to structure rake files and get tips for running scripts in parallel. In working with this software, I have become very familiar with the files in the rspec, deeptest, and selenium-client gems.
September 20, 2009, 9:10 pm
I have noticed this alert showing up when I start Firefox. After experimenting, I have found the solution. On a Mac go into th ~/Library/Application Support/Firefox/Profiles directory and cd into your profile’s directory. Remove the cert8.db file and restart Firefox. Firefox will regenerate a new file and sites that use https will start working again.

September 14, 2009, 3:49 pm
I dock my Mac laptop and use an external keyboard. I map my dell keyboard so that the command key is in the same place as on the laptop. This lets me use the alt key as command and the windows key as the alt/option key. I had a problem when I undocked, the laptop mixed up the key mapping and the alt and command keys were reversed. I used the keyboard setting tab multiple times to reset the keys do default without any success. To fix the problem I plugged in both keyboards and selected the all option from the keyboard drop down list. Then I deleted /Library/Preferences/com.apple.keyboardtype.plist and reconfigured both keyboards. I spend weeks trying to figure out why my keyboard mapping was wrong on my laptop.

September 14, 2009, 11:33 am
I started using custom Firefox profiles so that I could get around the self signed cert error in firefox. I found a way to easily maintain one configured profile that is used across all Selenium remote control environments running on OS X and multiple windows versions.
- Download the selenium grid software. I am using selenium-grid-1.0.4
- Create a new directory called SeleniumFireFoxProfile in your selenium-grid-1.0.4 directory.
- Start your remote control using the custom profile. rake all:start SELENIUM_ARGS=”-firefoxProfileTemplate SeleniumFireFoxProfile”
- Create a test script to open a selenium client driver and navigate to the site that is getting the ssl cert error. Use a debugger to pause the execution of your script at the browser.open command
- Execute your script to the break point and accept the cert in your Firefox browser.
- Look for the creation of the cert_override.txt file in your user directory. With Firefox 3.0 I found it on my mac in /private/var/folders. I cd to the contained directory and run a find command to locate it sudo find . -name cert_override.txt. With Firefox 3.5 the profile is stored in the user directory ~/Library/Application Support/Firefox/Profiles.
- You should see an entry in your cert_override.txt file after you accept the certificate. Now copy the cert_override.txt from your user directory to your SeleniumFireFoxProfile directory in your selenium grid directory.
- Restart your remote control now using the profile with the cert_override.txt file in it. Rerun your test and break on the open command now you should see your page render instead of the security warning.
Just a warning about the cert_override.txt file. It is very white space sensitive, it is better to copy the whole file into your custom profile directory rather then copying a new line into an existing file.
I check in the override text file along with my selenium software. This way I can add a cert on my local machine and then run a SVN update on the distributed grid hosts to get the new cert information. This works for both windows and OS X.
August 25, 2009, 3:59 pm
This post explains how to debug a Selenium test script in Rubymine like you would in the selenium IDE. It is common to have a missing element failure in a recorded selenium script. A quick way to debug this in the Selnium IDE is to put a break point in your script and use the execute command button to find the right code for your failing command.

Add breakpoints start and stop test execution
In the case of a failing script you can see below that the failing line is highlighted in red and you can see the log message explaining the error.

Failing script
So when you export your selenium IDE script to your favorite language, how do you trouble shoot failures like this easily in your development environment?

Test Script
I generated an error in the script by changing the name of the google button from “btnG” to “btn” . Trouble shoot this error by using the Rubymine debugger and evaluate expression tool. I put a break point on the line of code that is failing. Then I can select the text and open the evaluate expression tool to see if I can locate the button.

When you get the expression correct, you will see a message, result = nil. This is a great tool for testing xpath expressions.

Successful Evaluation
If you noticed that the code I used in this example is different than what is exported from the Selenium IDE, it is because I use the selenium-client gem and execute my tests using the selenium grid.
July 31, 2009, 8:04 pm
I just discovered a new program for the Mac called Gowl. It was a piggy back program installed with drop box. The name is cheesy but I like what the program does. As your working throughout the day you have emails, updates from Skype, and updates from Tweetdeck. There are many different programs that present messages. I don’t want to cmd tab to all of the different programs to see if the status of a new message is important. Growl lets me look in the top right corner of my screen to get messages from a number of different programs. Growl also interfaces with rubymine and firefox.

July 31, 2009, 6:17 pm
I have been convinced in to starting a technical blog like many of my technology colleagues in Austin. I will be posting information as I learn from my work experiences so that I can help better the coding community.