Skip to content

Commit

Permalink
Better instructions for avoiding sleep() and wait().
Browse files Browse the repository at this point in the history
  • Loading branch information
kablamo committed Feb 27, 2012
1 parent 1d7566f commit d8b3eff
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/Test/WWW/Selenium/More/Manual/BestPractices.pod
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@ Following these guidelines will make your life easier when writing Selenium
tests. They are listed in order of importance.


=head2 If you use jQuery, never ever never pause() or sleep()
=head2 Don't use pause() or sleep()

Many people use pause() or sleep() because wait_for_page_to_load_ok() doesn't
work for them. The reason it doesn't work is because page components are
loading via JavaScript and wait_for_page_to_load_ok() doesn't concern itself
with anything JavaScript related.
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 because page components
are loading via JavaScript and wait_for_page_to_load_ok() doesn't concern
itself with anything JavaScript related.

But using these methods will make your tests take a long time and will cause
hard to reproduce intermittent failures and generally drive you crazy.

The solution is to always use wait_for_page_to_load_ok() when there is no AJAXy
jQueryy behavior happening and to use jquery_wait_for_page_to_load_ok() there
is. Or use methods which call them underneath like follow_link_ok() and
jquery_click_ok().
If your page uses jQuery, use jquery_wait_for_page_to_load_ok().

Unfortunately this solution only works with jQuery.
If your page doesn't use jQuery you can use wait_for_text_present_ok() in most
cases.

=head2 Always use XPATH locators

Expand Down

0 comments on commit d8b3eff

Please sign in to comment.