Please post your Web Driver questions in official Web Driver forum

Friday, January 20, 2012

An open billet doux to beloved manager

Dear manager,

I never imagined that I would ever write an open love letter to you but having worked with you for so long I am drowning in the sea of love and can not help but let the world know of my feelings for you. Since you like the bullet points I am following the same. (Sorry, could not do Microsoft excel for this. Please bear with me for not letting you create pivot table this time). Here I go -
  • Some time quick and dirty is good. We should have followed it in stand up meetings at least! Those meeting which soon became Sitting Meetings and later Sleeping Meeting.
  • Forcing me to find significant improvement areas in project every fortnight (sigh). Dear, if there were possibilities to do it so frequently then there must have been some thing badly wrong with project.
  • You wanted me to test 24/7. Your Keep Testing arguments are always roaming on my mind. And if that was not enough you asked me to write that stupid certificate. I wish I had done that as there are enough foolish companies which consider testing certificate no less than bible. And I would have broken the shackles of this relation.
  • You asked me for test status every half an hour. I understand your feelings for me but some times we need to be more patient with things.

Friday, January 6, 2012

Selenium 2 methods are no more Weird!!!

tl;dr A long post about using Selenium 1 sort syntax with Selenium 2/WebDriver.

I have seen automation teams suffering from verbosity of web driver way of writing code. One automation guy told me once that he does not want to use Selenium 2 on a brand new project because he finds its syntax utterly weird. But before discussing "Weirdness" of Selenium 2 syntax, let us agree on fact that teams migrating from pure manual testing to automation code find it more weird than ever. While selenium.type("elementLocator", "testData") looks simple to them. Using driver.findElement(By.xPath).sendKeys("testData") looks excessive coding to be able to perform same operation.
Herein I am illustrating the way to wrap Selenium 1 and Selenium 2/WebDriver methods. Don't consider this as the only way of wrapping, I am sure there are better solutions than this.

This is how Selenium1 code (Google again) goes. In the following example there are 5 basic entities -

  • SelTestCase class - which sets up test bed for Selenium
  • ActionDriver class - which carries out operations on page
  • Page element classes - which store element locators
  • Page object classes - which represents services offered by page and

Thursday, January 5, 2012

What ??? - "com.thoughtworks.selenium.SeleniumException: syntax error"

At times during development of Selenium tests you come across errors which don't give you any clue what so ever. One such error is -

com.thoughtworks.selenium.SeleniumException: syntax error
or -
missing ) after argument list

One such occurnce of this error is when you use waitForCondition method.
This is one awesome selenium method which saved you from using ugly sleep statements in your scripts. Having read it's API you might consider using it as -

waitForCondition("selenium.isElementPresent(//a[text()='Dashboard'])", "60000");

where first argument - selenium.isElementPresent(//a[text()='Dashboard']), is the condition you expect to be true. And second argument - 60000, is the max wait period till selenium would wait for condition to be true (You don't hard code time in your scripts, do you?).

Tuesday, January 3, 2012

Updating Sauce Labs dashboard with Selenium 2 test results


If you have not yet known of Sauce Labs, Sauce Labs specialises in executing Selenium tests on cloud. If you don't want to manage those umpteen configurations for executing your Selenium tests, then Sauce Labs is the answer. I am not going to explain executing your Selenium tests on Sauce Labs as there is enough documentation on Sauce Labs which already explains this. What I was stuck with is updating test results on Sauce Labs dashboard. Status "finished" does not indicate about success/failure of tests and you may probably not have time to see log/video of each and every finished tests.



I posted query to Sauce Labs and got to know about the Sauce Labs REST api. But things were still not very clear as I was not sure of on what basis I could update test results in Sauce Labs dashboard.
Fork me on GitHub