Wednesday 9 February 2011

Lessons from a WATIR to WATIR-Webdriver port - #4 When assert_true is no longer assert_true

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!



3 comments:

  1. This is a good series of posts. I am currently undertaking a similar task and investigating the watir-webdriver for implementation.
    Up till now thou i have not been that impressed, although this could be down to a poor implementation on my part.
    some of the things i have had trouble with are:
    1. select_list and set now being select and select
    2. Additional "hand holding" (adding in extra steps to help find and click elements on the page) of the tests where as watir and firewatir have had no problems finding these elements.
    3. The speed compared to watir seems to be pretty slow. firewatir has always been slow in my implementation and webdriver seems to be a little slower if not by much. to give an example of the last point, my test file i have been using takes 3 minutes to run in watir but over 6 minutes to run with the webdriver and firewatir.

    If you have any tips on getting it speeded up or the other issues i have noted here i would be very grateful.

    ReplyDelete
  2. Hi Keith,

    Speed issues? Are you using an existing firefox profile? Webdriver has to copy the profile to a temporary location, and this can be slow.

    Actually, there is no need to ever use an existing firefox profile with Watir-Webdriver. You should be able to create a new "blank" profile then programmatically set any "about:config" and attach any "add ins". There are a few examples of this on the web.

    With regards to "hand holding", you can of course override the built in methods (e.g override "click" on "button" to do something else before clicking)

    Finally, if want to be impressed with Watir-Webdriver, read my next post (hopefully in the next or two)

    ReplyDelete
  3. To be honest the changes to the tests in order to update to the webdriver are not that bad, its just additional work i dont have time to implement, as it means time tweaking are build server.
    In regards to the speed problems, these are a real issue for me, but as i said im not sure this is firewatir or the webdriver but more my implementation as i havnt seen anyone else complaining of having this issue. I know firewatir is a bit slower that watir because of the use of jssh, but the slow times i am experiencing i am sure must be down to something more. Currently on our server and my local machine 1 of my feature files takes 4:32 to run in watir but 13:11 to run in firewatir. this is having serious impact on my test run times. If you have any handy experience to pass down regarding how to speed firewatir up (such as the profiles setup you mentioned) i would be very grateful to hear.
    the webdriver is not ness the way forward to fixing these issues above as i said before i have not seen the speed improvements with it, it could be the same thing slowing firewatir down is doing the same tot he webdriver.
    Thanks

    ReplyDelete