- BEST PRACTICES
- COPYRIGHT AND LICENSE
Following these guidelines will make your life easier when writing Selenium tests. They are listed in order of importance.
Don't use pause() or sleep()
However using these methods will make your tests take a long time and will cause hard to reproduce intermittent failures and generally drive you crazy.
If your page uses jQuery, use jquery_wait_for_page_to_load_ok().
If your page doesn't use jQuery you can use wait_for_text_present_ok() in most cases.
Use XPATH locators
CSS can't choose the nth thing in a list or table. XPATH can. For the sake of consistency you may want to stay with XPATH.
Use comments when things get complicated
Most methods allow you to pass along a comment. The comment shows up in your TAP output.
For example. Sometimes when using XPATH, you should add a comment to the test output. You can do that like this:
$selenium->click_ok('//table/tbody/tr/td/input[name=foo]', "click 3rd checkbox")
Use $selenium->note() to document your tests
This works like Test::More::note().
Eric Johnson <kablamo at iijo dot nospamthanks dot org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Eric Johnson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.