Selenium Fury 5.5 released
I was able to restructure the gem and remove the dependency on Rspec. I have tested successfully with Rspec 1 and 2.
Coding and Technical Tips
Archive for the ‘rspec’ Category.
I was able to restructure the gem and remove the dependency on Rspec. I have tested successfully with Rspec 1 and 2.
I have been working on converting our page object factory to open source for a few weeks. Now it is time to launch the HomeAway sponsored open source project under the Apache 2.0 license. It is a furiously quick way to implement test automation. I am planning to add more configuration options in the future.
This project started when I had to test a page with 300+ check boxes and I did not want to enter them by hand. I used the page object generator to build a page of ruby variables with Selenium locators. Everything was great until some number of the check boxes changed their ids and my tests started failing. I needed a quick way to find out how many changed so I could update the locators by hand or regenerate the page. This is where the validators came in. I used Ruby’s support of reflection to open a class, navigate to the url of the page and use Selenium to validate the locators and return a list of missing locators on the page. It worked perfectly for my page of 300+ check boxes. I had over 40 that changed I quickly regenerated the page.
Install with:
Checkout the home page and examples at https://github.com/scottcsims/SeleniumFury
Thanks to HomeAway for sponsoring this project.
I wanted to test an error message in my class that processes test results and sends them to Rally. The problem was that I did not want to actually create a rally object and run the method to parse the results, just to test the error message.
This is what my class looks like.
class AutomationRun def send_results_to_rally @rally = RallyUtils.new(ENV['RALLY_WORKSPACE']) push_test_case_results raise("Test Case Results Were Not Parsed Correctly") if test_case_results.empty? test_case_results.each do |result| @rally.update_test_case_result(:tc_id =>result.test_case_number_from_spec_report, :build =>result.build_number, :verdict =>result.verdict, :notes => result.note.format_note) end end end
I want to skip these steps to test the error message:
This is what my test code looks like:
it "should raise an exception if there are not test case results" do RallyUtils.stub!(:new).and_return(nil) automation_run=AutomationRun.new automation_run.should_receive(:push_test_case_results).and_return([]) begin automation_run.send_results_to_rally rescue Exception=>e end e.message.should == "Test Case Results Were Not Parsed Correctly" end
So that is it, I created a partial mock in that we are using a real automation run object but we stubbed out one of the methods. We also stubbed out the new call to rally so we don’t create a connection. Now I can focus my test on exactly the function I wanted to test, the error message.