Archive for the ‘Uncategorized’ Category.
October 15, 2010, 12:07 pm
I am looking forward to my first trip to Las Vegas http://www.stpcon.com/. I will have a chance to meet with other selenium grid users and test out my strategies in test automation patterns. I will be attending all of the topics on agile automation
Category:
Uncategorized |
Comments Off on Going to Software Test Professionals Conference next week.
May 7, 2010, 12:53 pm
What I have already done to update the ruby example in the Selenium Grid repo. Code Link
- Updated rspec from 1.1.8 to 1.1.12. I accomplished this by getting the most recent deep-test code and adding it to the /lib directory. The new version of the deep test code supports rspec 1.1.12. I then just require it in in the rake file. require File.expand_path(File.dirname(__FILE__) + ‘/lib/deep_test/rake_tasks’)
- The rake file does not need selenium-client 1.2.7. I removed the dependency by adding the reporting files it was referencing into the lib/reporting directory. report_formatter_path = “lib/reporting/selenium_test_report_formatter”
- Updated selenium-client from 1.2.7 to 1.2.18. With the change to the rake file, I am now able to use the most recent version of selenium-client in my specs.
Other helpful tools/tricks I have added to selenium grid (Maybe useful to other Ruby/Grid users)
- I start and stop the grid from the same rake file that I execute the tests from. Examples are grid:all_start and spec:run_in_parallel
- Rake tasks can just run and create a HTML report or run and send test results to Rally
- The tests and rake file runs on OS X, Cent OS, and Windows. (no parallelizaion on windows)
- Specify command options to the rake tasks to switch between hostnames I am running against. (This is useful when you have more than one instance like test.yourdomain.com and stage.yourdomain.com)
- Specify to only run tests for specific sites in the test suit. For example if you wrote tests for www.yourdomain.com and www.yourdomain.es. You can specify which sites to run against
- I use gem bundler with all grid projects to help control gem installation and versions. (My Rakefile automatically installs needed gems if you don’t have them)
- I have a framework for creating ruby classes with selenium locators automatically. I use nokogiri to help with this.
- Spec test to open ruby classes with locators and create a report of all of the changed selenium locators.
Future Goals
- Update Deep Test so that it uses the same version(1.2.8) of rspec as the latest version of Selenium-Client. Right now we are at rspec 1.1.12 and selenium client 1.2.18. Selenium-Client 1.2.18 can use rspec 1.2.8.
- When rspec is updated, I will be able to use the selenium client to provide screen shots if needed
- Figure out how to create a formatter that allows the Team City and Rubymine spec runners to provide the same test runner template as it does for test in sequence when you run test in parallel in deep test.
Rubymine Spec Formatter
April 12, 2010, 8:28 am
I am impressed with the new logging and stability features of Selenium-Client 1.2.18. One of the most useful improvements is the automatic failure when a page is showing service unavailable.
I used to put a line like this after every browser.open command.
browser.text?("Http/1.1 Service Unavailable").should(be_false)
Now I get a nice error message from the Selenium-Client.
Selenium::CommandError: Response_Code = 503 Error_Message = Service Unavailable
Category:
Uncategorized |
Comments Off on Selenium-Client 1.2.18 has excellent logging and error messages.
February 2, 2010, 10:36 am
I like to navigate through Rubymine using only keyboard shortcuts if I can. One of the most useful techniques I have found is mapping a keyboard shortcut to enable you to run the test that your cursor is on. This way you can navigate up and down tests using ctl + up or down and then run the test your interested in with your key stroke. Even though I am on a Mac I prefer running a test to be mapped to control + t. The default configuration for this is command + alt + F8. The keymap configuration is under the label Run context configuration, which is under the All Actions -> Other section in the Keymap configuration menu.
The other shortcut that goes well with this one is Go To Test. I can put my cursor on a class name and press alt+shift+t and I can view the tests implementation for this class. Then I can use the short cut I created ctrl + t to run a test I am interested in.
Category:
Uncategorized |
Comments Off on Test navigation in Rubymine (control +T )
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.
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.