Sunday, February 17, 2013

Validating WebDriver Tests Without the WebDriver API

One thing we have noticed working on WebTestingExplorer is just how excruciatingly slow WebDriver can be. Perhaps you have never noticed this because you only validate a few elements at the end of a WebDriver test. But in WebTestingExplorer use cases, we often need to examine hundreds and hundreds of WebElements and their attribute values after each action. And here, WebDriver's architecture where every call to the browser is a local RPC is a massive fail in terms of performance (and, I think, stability, although that is harder to pin down).

This is one of the (many) reasons I wish the testing practice was not standardizing on WebDriver: I feel like browser automation is far from a solved problem and would like to see what other smart people can continue to put forward. Nonetheless, we feel like we have to use it for WebTestingExplorer, both to provide synergy and integration between our tool and other testing efforts, and because there just aren't a lot of good alternatives under active development.

That said, we had been theorizing for awhile that we could improve life significantly if we started trying to implement WebTestingExplorer state checking and oracles on top of an alternative HTML-parsing library. A couple of weeks ago, I selected jsoup as the library and finally took a shot at this. The results were really incredible -- an order of magnitude or more speedup in many of our exploration and bug-checking scenarios, and fewer (read: zero) inexplicable, random exceptions flying out of WebDriver. Going forward, I hope to try and rework some of the WebTestingExplorer APIs to make this more natural.

But even if you're not using WebTestingExplorer, I think the overall approach is worth considering for any web unit/system/integration testing you might be doing. The idea is to command the browser using WebDriver as you normally do. Then, having completed that, grab the current DOM HTML of the page with WebDriver like this:

WebDriver driver;
// ...
JavascriptExecutor js = (JavascriptExecutordriver;
String domString = (Stringjs.executeScript("return document.documentElement.outerHTML;");

Done with WebDriver, feed that to the jsoup parser and enjoy its simple, fast API while writing your assertions. Yeah, you lose all the fancy element-is-displayed logic that WebDriver is constantly trying to perform, but hopefully (as in, you would think) it's not too hard to write assertions that don't care much about that. Enjoy!


burnetandy79 said...

I just wanted to comment your blog and say that I really enjoyed reading your blog post here. It was very informative and I also digg the way you write! Keep it up and I’ll be back to read more soon mate.I also provide this service u can visit my site.
drupal 7 development

Jessi Gianni said...

Thanks for the information and if you are looking into selling your car, check out we buy junk cars orlando

jackbroobgm said...

Verification and Validation are the activities performed to improve the quality and reliability of the system and assure the product satisfies the customer needs.
Verification assures the product of each development phase meets their respective requirements.
Validation assures the final product meets the client requirements.

software validation

Kevin Petter said...

I also tell my team members to spend qaulity time doing analysis of the work they do. Do not spend the entire day in just doing testing.
Spending everyday sometime on Analysis will help them
to move in the right direction in the work and also helps them to see in a bigger and broader perspective of the work.
Finally, just spend good amount of time in planning, reviews and analysis, the execution will be done like in no time.

equipment validation
labview programming
software validation

Madness Gabrill said...

The ability of prerequisites to streamline the execution of a qualification,
with the added bonus of the ways that they benefit a quality system,
demonstrates the value of incorporating prerequisites into an equipment qualification.This service saves you time and money,
as you can review these digital representations.

equipment validation

Madness Gabrill said...

Very well written.As the latest validation guidance is having terms like verification and testing its good to add ISO documents also in the requirements list.
The whole article gave a clear path where and how to start.
I thank the moderator for sharing such a good article.- See more at:

equipment validation