I wanted to record problems found (and perhaps solved?) while attempting to port a test automation framework from WATIR to WATIR - Webdriver, and a simple blog entry seemed to be the easiest way.
This problem may be just faced by myself and the caused by the versions of TestUnit, Watir & Webdriver I am using, but just in case other people are having the same issue, here it is for google to find!
For the same test, Assert_True was passing when using WATIR, but failing when using Watir-Webdriver.
After tearing my hair out for a while I realised that when using WATIR, assert_true comes from more-assertions.rb in a gem called s4t-utils, where as when I ran the test as WATIR-Webdriver, the assert_true from the testunit gem is used.
The assert_true in TestUnit gem is far stricter in that the value must be boolean true to pass, where as the other assert_true takes advantage of the fact that in Ruby, anything which isn't nil is true.
Personally, I like the version which insists the value is boolean true, so have decided to change the tests to follow this, although obviously I could have overridden it with the less strict version.
As I said, this problem will not affect everyone, perhaps it's only me, but I wanted it recorded!
Wednesday, 9 February 2011
Lessons from a WATIR to WATIR-Webdriver port - #3 Ruby meets strong typing
I wanted to record problems found (and perhaps solved?) while attempting to port a test automation framework from WATIR to WATIR - Webdriver, and a simple blog entry seemed to be the easiest way.
WATIR is far less strict than Webdriver about the classes you use to access objects in the html, presumably this because Webdriver is written in Java(???) and that is derives its tag_name from teh class itself.
If I have a visible object which looks like a button but in the html is actually a link, then WATIR is far more forgiving.
For example;
<a href="http://www.google.com" id="goog">Goto Google</a>
Using id, WATIR allows me several ways to access the object, such as;
@browser.button(:id, "goog")
@browser.link(:id, "goog")
However, with Webdriver, I have to use the class define in the html. Therefore only the following is valid.
@browser.link(:id, "goog") NB. I believe Link is an alias of "a", therefore "a" is valid too
If you were to use "button", you would get the following error;
Watir::Exception::UnknownObjectException: unable to locate element, using {:tag_name=>"button", :id=>"goog"}
This is obviously not a big problem, but as I said, exposes mistakes which WATIR allowed and requires changes if those mistakes were made
WATIR is far less strict than Webdriver about the classes you use to access objects in the html, presumably this because Webdriver is written in Java(???) and that is derives its tag_name from teh class itself.
If I have a visible object which looks like a button but in the html is actually a link, then WATIR is far more forgiving.
For example;
<a href="http://www.google.com" id="goog">Goto Google</a>
Using id, WATIR allows me several ways to access the object, such as;
@browser.button(:id, "goog")
@browser.link(:id, "goog")
However, with Webdriver, I have to use the class define in the html. Therefore only the following is valid.
@browser.link(:id, "goog") NB. I believe Link is an alias of "a", therefore "a" is valid too
If you were to use "button", you would get the following error;
Watir::Exception::UnknownObjectException: unable to locate element, using {:tag_name=>"button", :id=>"goog"}
This is obviously not a big problem, but as I said, exposes mistakes which WATIR allowed and requires changes if those mistakes were made
Tuesday, 8 February 2011
Lessons from a WATIR to WATIR-Webdriver port - #2 Add_checker can still be my friend
I wanted to record problems found (and perhaps solved?) while attempting to port a test automation framework from WATIR to WATIR - Webdriver, and a simple blog entry seemed to be the easiest way.
As a result, it was assumed that;
add_checker + webdriver = BAD
However, this is not true. The reason the add_checkers appeared to be slow on IE, was because we used the Text method on the Browser class to scan for certain text on the page. This is extremely slow in IE for webdriver.
Therefore, add_checkers can be used in webdriver as long as you do not use browser.text
Monday, 7 February 2011
Lessons from a WATIR to WATIR-Webdriver port - #1 When it comes to Firefox, size matters
I wanted to record problems found (and perhaps solved?) while attempting to port a test automation framework from WATIR to WATIR - Webdriver, and a simple blog entry seemed to be the easiest way.
Slow Firefox Startup
I was finding that it was taking upwards of 30 seconds to launch Firefox at the start of a test. This compared badly with WATIR, where the same test was a few seconds.
The problem;
As part of Selenium::WebDriver::Firefox::Launcher, the FF profile is copied to a temporary folder. This uses FileUtils.cp_r and appears to be slow.
The solution:
Make sure the firefox profile used on your test run machine is as small as possible. I removed Firebug, EditCookies and a few other add-ons, and this reduced the start up time to a few seconds and comparable to WATIR
Slow Firefox Startup
I was finding that it was taking upwards of 30 seconds to launch Firefox at the start of a test. This compared badly with WATIR, where the same test was a few seconds.
The problem;
As part of Selenium::WebDriver::Firefox::Launcher, the FF profile is copied to a temporary folder. This uses FileUtils.cp_r and appears to be slow.
The solution:
Make sure the firefox profile used on your test run machine is as small as possible. I removed Firebug, EditCookies and a few other add-ons, and this reduced the start up time to a few seconds and comparable to WATIR
Wednesday, 8 December 2010
Introducing the Test Automation Fire Triangle
It is a fact that while some test automation projects succeed, a lot, if not the majority, fail. With this in mind, I tried to establish what the common factors are in a successful test automation project, independent of the system under test. Factors which were true whether the automation is User Interface, REST, SOAP, etc.
I identified 3 cornerstones of a successful project, and then realised how it was very similar to the Fire Triangle we all learnt in our science lessons at school.
A brief recap of the Fire Triangle can be found here (http://en.wikipedia.org/wiki/Fire_triangle ) but the general concept that is that without the elements: heat, fuel and oxygen, then a fire cannot start or continue. All three elements are as key as each other.
I believe that in Test Automation, these elements can be replaced with; Stability, Maintainability and Scalability. Each is as key as each other, and without all three, your project will struggle. When designing or evaluating your test automation framework, all three must be a consideration from the start, even if not immediately an issue, they will eventually be required. Within a short space of time your test automation framework will become Shelfware.
Stability
Without a reliable way of identifying objects and stable running mechanism;
- Test results are not reliable
- Manual interaction may be required to ensure full runs
- CI is not possible
Maintainability
The framework must adaptable to change. Object identifiers may be updated, xml formats can be updated. Your framework must be more Agile then the SUT it is testing else;
- Tests will not be able to run when required
- More time will be spent re-engineering the tests than developing the SUT
- Automated tests will not be be part of the development sign off
Scalability
Okay, so you've got a great stable and maintainable framework, you have hundreds, if not thousands of really fantastic tests which will give you immediate feedback of any broken code. Well, when you say immediate, you mean 24 hours! One machine running all the tests is not a solution going forward. You need lots of machines, but for this you will need lots of licenses if not open source. Even then you need a mechanism to control and collate test running and results. Without this;
- The framework becomes too expensive (20 x QTP licenses is a lot of money!)
- CI cannot be achieved
- Test runs take too long to be of any use in an Agile project
Conclusion
I am not saying that these 3 elements are the only things required for a successful project, but other decisions are dependent on the SUT itself. For example;
- Useability (ie. how easy is it to write scripts) - this is dependent on the audience the tool is aimed at.
- Readability - Are you expecting people to read scripts who do not write them?
- Cross-platform - Is the SUT strictly one platform only?
My main message is that the 3 elements in the Test Automation Fire Triangle are key to every test automation project. Without these, your test automation will fail. Maybe not immediately if you have the Stability sorted, but as the SUT grows, lack of planning and foresight in Maintainability and Scalability will mean that your Test Framework will struggle to grow with it, and ultimately end up on the Test Automation scrapheap, along with so many of it's friends.
Subscribe to:
Posts (Atom)
