Eric D Johnson > Test-WWW-Selenium-More-0.12 > Test::WWW::Selenium::More::Manual::BestPractices

Download:
Test-WWW-Selenium-More-0.12.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.12   Source  

NAME ^

Test::WWW::Selenium::More::Manual::BestPractices

NAME ^

Test::WWW::Selenium::More::Manual::BestPractices

BEST PRACTICES ^

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()

Sometimes people use pause() or sleep() because wait_for_page_to_load_ok() doesn't work for them. The reason it doesn't work is page components are loading via JavaScript and wait_for_page_to_load_ok() ignores anything JavaScript related.

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[3]/td/input[name=foo]', "click 3rd checkbox")

Use $selenium->note() to document your tests

This works like Test::More::note().

AUTHOR ^

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.

syntax highlighting: