Commit 39d5b661 39d5b661f31616ff663bf4ab17d86484bfce0cec by Nicolas Perriault

added Casper#exists() method to check for a DOM element

1 parent 0e6b9a67
...@@ -306,6 +306,20 @@ ...@@ -306,6 +306,20 @@
306 }, 306 },
307 307
308 /** 308 /**
309 * Checks if an element matching the provided CSS3 selector exists in
310 * current page DOM.
311 *
312 * @return Boolean
313 */
314 exists: function(selector) {
315 return self.evaluate(function() {
316 return __utils__.exists('%selector%');
317 }, {
318 selector: selector
319 });
320 };
321
322 /**
309 * Fills a form with provided field values. 323 * Fills a form with provided field values.
310 * 324 *
311 * @param String selector A CSS3 selector to the target form to fill 325 * @param String selector A CSS3 selector to the target form to fill
......
...@@ -41,6 +41,10 @@ phantom.Casper.extend({ ...@@ -41,6 +41,10 @@ phantom.Casper.extend({
41 return this.assert(pattern.test(subject), message); 41 return this.assert(pattern.test(subject), message);
42 }, 42 },
43 43
44 assertSelectorExists: function(selector, message) {
45 return this.assert(this.exists(selector), message);
46 },
47
44 assertTitle: function(expected, message) { 48 assertTitle: function(expected, message) {
45 return this.assertEvalEquals(function() { 49 return this.assertEvalEquals(function() {
46 return document.title; 50 return document.title;
......