Commit 8a3996b6 8a3996b6cfc06ff098057afffd94fed17d532ce8 by Nicolas Perriault

added Casper.thenClick() to add a new step for clicking a link (@marchugon)

1 parent 03cd587d
......@@ -225,21 +225,6 @@
},
/**
* Adds a new navigation step for clicking on a provided link.
*
* @param String selector A DOM CSS3 compatible selector
* @param function then Next step function to execute on page loaded (optional)
* @return Casper
* @see Casper#open
*/
thenClick: function(selector, fallbackToHref, then) {
this.then(function(self) {
self.click(selector, fallbackToHref);
});
return typeof then === "function" ? this.then(then) : this;
},
/**
* Logs the HTML code of the current page.
*
* @return Casper
......@@ -649,6 +634,24 @@
},
/**
* Adds a new navigation step for clicking on a provided link selector
* and execute an optional next step.
*
* @param String selector A DOM CSS3 compatible selector
* @param Function then Next step function to execute on page loaded (optional)
* @param Boolean fallbackToHref Whether to try to relocate to the value of any href attribute (default: true)
* @return Casper
* @see Casper#click
* @see Casper#then
*/
thenClick: function(selector, then, fallbackToHref) {
this.then(function(self) {
self.click(selector, fallbackToHref);
});
return typeof then === "function" ? this.then(then) : this;
},
/**
* Adds a new navigation step to perform code evaluation within the
* current retrieved page DOM.
*
......
......@@ -145,6 +145,12 @@ casper.then(function(self) {
self.test.assertUrlMatch(/topic=bar/, 'fill() select field was submitted');
});
// Casper#thenClick()
casper.thenClick('body a', function(self) {
self.test.comment('Casper.thenClick()');
self.test.assertTitle('CasperJS test index', 'thenClick() casper can add a step for clicking a link');
});
// Casper#each()
casper.test.comment('each');
casper.each([1, 2, 3], function(self, item, i) {
......
......@@ -5,6 +5,7 @@
<title>CasperJS test form result</title>
</head>
<body>
this is the result page
<p>this is the result page</p>
<p><a href="index.html">Return back home</a></p>
</body>
</html>
\ No newline at end of file
......