switched to more standard .textContent property to get node text
Showing
4 changed files
with
5 additions
and
5 deletions
... | @@ -349,7 +349,7 @@ Casper.prototype.debugHTML = function debugHTML() { | ... | @@ -349,7 +349,7 @@ Casper.prototype.debugHTML = function debugHTML() { |
349 | */ | 349 | */ |
350 | Casper.prototype.debugPage = function debugPage() { | 350 | Casper.prototype.debugPage = function debugPage() { |
351 | this.echo(this.evaluate(function _evaluate() { | 351 | this.echo(this.evaluate(function _evaluate() { |
352 | return document.body.innerText; | 352 | return document.body.textContent || document.body.innerText; |
353 | })); | 353 | })); |
354 | return this; | 354 | return this; |
355 | }; | 355 | }; | ... | ... |
... | @@ -165,7 +165,7 @@ | ... | @@ -165,7 +165,7 @@ |
165 | var text = '', elements = this.findAll(selector); | 165 | var text = '', elements = this.findAll(selector); |
166 | if (elements && elements.length) { | 166 | if (elements && elements.length) { |
167 | Array.prototype.forEach.call(elements, function _forEach(element) { | 167 | Array.prototype.forEach.call(elements, function _forEach(element) { |
168 | text += element.innerText; | 168 | text += element.textContent || element.innerText; |
169 | }); | 169 | }); |
170 | } | 170 | } |
171 | return text; | 171 | return text; | ... | ... |
... | @@ -355,8 +355,8 @@ var Tester = function Tester(casper, options) { | ... | @@ -355,8 +355,8 @@ var Tester = function Tester(casper, options) { |
355 | */ | 355 | */ |
356 | this.assertTextExists = this.assertTextExist = function assertTextExists(text, message) { | 356 | this.assertTextExists = this.assertTextExist = function assertTextExists(text, message) { |
357 | var textFound = (casper.evaluate(function _evaluate() { | 357 | var textFound = (casper.evaluate(function _evaluate() { |
358 | return document.body.innerText; | 358 | return document.body.textContent || document.body.innerText; |
359 | }).indexOf(text) != -1); | 359 | }).indexOf(text) !== -1); |
360 | return this.assert(textFound, message, { | 360 | return this.assert(textFound, message, { |
361 | type: "assertTextExists", | 361 | type: "assertTextExists", |
362 | details: "Text was not found within the document body textual contents", | 362 | details: "Text was not found within the document body textual contents", | ... | ... |
-
Please register or sign in to post a comment