refs #889 - added warning about using then() vs. waitFor*()
Showing
1 changed file
with
21 additions
and
0 deletions
... | @@ -1744,6 +1744,27 @@ To run all the steps you defined, call the `run()`_ method, and voila. | ... | @@ -1744,6 +1744,27 @@ To run all the steps you defined, call the `run()`_ method, and voila. |
1744 | $ casperjs dump-headers.js | 1744 | $ casperjs dump-headers.js |
1745 | Thu, 18 Oct 2012 08:26:34 GMT | 1745 | Thu, 18 Oct 2012 08:26:34 GMT |
1746 | 1746 | ||
1747 | .. index:: DOMReady | ||
1748 | |||
1749 | .. warning:: | ||
1750 | |||
1751 | Step functions added to `then()` are processed in two different cases: | ||
1752 | |||
1753 | 1. when the previous step function has been executed, | ||
1754 | 2. when the previous main HTTP request has been executed and the page *loaded*; | ||
1755 | |||
1756 | Note that there's no single definition of *page loaded*; is it when the ``DOMReady`` event has been triggered? Is it "all requests being finished"? Is it *all application logic being performed"? Or "all elements being rendered"? The answer always depends on the context. Hence why you're encouraged to always use the `waitFor()`_ family methods to keep explicit control on what you actually expect. | ||
1757 | |||
1758 | A common trick is to use `waitForSelector()`_:: | ||
1759 | |||
1760 | casper.start('http://my.website.com/'); | ||
1761 | |||
1762 | casper.waitForSelector("#plop", function() { | ||
1763 | this.echo("I'm sure #plop is available in the DOM"); | ||
1764 | }); | ||
1765 | |||
1766 | casper.run(); | ||
1767 | |||
1747 | .. index:: bypass, Step stack | 1768 | .. index:: bypass, Step stack |
1748 | 1769 | ||
1749 | ``thenBypass()`` | 1770 | ``thenBypass()`` | ... | ... |
-
Please register or sign in to post a comment