devXero's blog

a blog about agile, development, and automation

  • tweets

    Error: Twitter did not respond. Please wait a few minutes and refresh this page.

  • photo

  • Advertisements

Ways to improve the reliability and efficiency of SWAT/UI tests (Part 3 – The truth behing AssertElementDoesNotExist)

Posted by Mike Longin on October 7, 2009

Were now up to part 3, and I am really thinking about ditching the numbers, I think this list is going to get very long very…

But on to part 3 and this will be a short one.  AssertElementDoesNotExist was one of the first commands created for SWAT.  Unfortunately many people do not know some of the dirty and dark secrets of this command.

You dont always know what you are looking for…

The most common mistake I see with this command is that people match it with a very complicated expression where many factors could make the command pass (which means the expression was NOT matched.)  In essence you get a false positive.



<a href="" id="myLink">Google</a>



Notice that I made a mistake with the href.  However because of that, this command would actually pass.  Which is one of the dangers of this command.

Its Slowwwwwwwwwwwwwwwwww

As you may or may not know, in your config file for SWAT you can set the default timeouts of many of the commands.  In almost all cases, as soon as SWAT finds an element it moves on to the next command.  However in the case of AssertElementDoesNotExist, SWAT will keep on searching through the length of the timeout.  Because of this, using a large amount of AssertElementDoesNotExist commands can drastically alter the time it takes to run your test.


7 second timeout

x 10 uses of the command


70 second minimum test run

So those are the dark secrets of AssertElementDoesNotExist.  What I try to tell people when it comes to this command, as with all commands, it should be thought about before using it.  I have seen many tests with 10 or 20 of these commands used in a row when it may have been possible to make do with less.  And in some cases, half of those commands were false to begin with.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: