Wednesday, April 14, 2010

Simple But Effective

Thought I would toss out a quick post about a few simple lines of code that came to save the day.

Have no fear If Else is here to save the day!

We do product line development where we have twelve unique products whose foundation is a common code base, but each product has variant points and are updated incrementally.

Recently we deployed 4 of the 12 products and numerous automation scripts broke.  With a little investigation there was a difference in a single page flow.

To the rescue was:

if browser.element? "some_css_locator"
    browser.click "some_css_locator", :wait_for => :page
else
end

All automation tests are now passing!

The really cool part is this code will work even if the new page flow is deployed to the other 8 products.

Long live css locators and the If Else!

No comments: