Commit 0b5aa6b0 0b5aa6b03a8ed53371dbee800ec648175b786dc3 by Nicolas Perriault

fixed Casper#exists(), added Casper.Tester#assertExists() method

1 parent 59984894
Showing 1 changed file with 26 additions and 12 deletions
...@@ -296,24 +296,14 @@ ...@@ -296,24 +296,14 @@
296 }, 296 },
297 297
298 /** 298 /**
299 * Exits phantom.
300 *
301 * @param Number status Status
302 * @return Casper
303 */
304 exit: function(status) {
305 phantom.exit(status);
306 return this;
307 },
308
309 /**
310 * Checks if an element matching the provided CSS3 selector exists in 299 * Checks if an element matching the provided CSS3 selector exists in
311 * current page DOM. 300 * current page DOM.
312 * 301 *
302 * @param String selector A CSS3 selector
313 * @return Boolean 303 * @return Boolean
314 */ 304 */
315 exists: function(selector) { 305 exists: function(selector) {
316 return self.evaluate(function() { 306 return this.evaluate(function() {
317 return __utils__.exists('%selector%'); 307 return __utils__.exists('%selector%');
318 }, { 308 }, {
319 selector: selector 309 selector: selector
...@@ -321,6 +311,17 @@ ...@@ -321,6 +311,17 @@
321 }, 311 },
322 312
323 /** 313 /**
314 * Exits phantom.
315 *
316 * @param Number status Status
317 * @return Casper
318 */
319 exit: function(status) {
320 phantom.exit(status);
321 return this;
322 },
323
324 /**
324 * Fills a form with provided field values. 325 * Fills a form with provided field values.
325 * 326 *
326 * @param String selector A CSS3 selector to the target form to fill 327 * @param String selector A CSS3 selector to the target form to fill
...@@ -983,6 +984,19 @@ ...@@ -983,6 +984,19 @@
983 }; 984 };
984 985
985 /** 986 /**
987 * Asserts that an element matching the provided CSS3 selector exists in
988 * remote DOM.
989 *
990 * @param String selector CSS3 selectore
991 * @param String message Test description
992 */
993 this.assertExists = function(selector, message) {
994 var f = casper.exists(selector)
995 console.log('plop')
996 return this.assert(casper.exists(selector), message);
997 };
998
999 /**
986 * Asserts that a provided string matches a provided RegExp pattern. 1000 * Asserts that a provided string matches a provided RegExp pattern.
987 * 1001 *
988 * @param String subject The string to test 1002 * @param String subject The string to test
......