Created
April 10, 2013 19:29
-
-
Save Meekohi/5357689 to your computer and use it in GitHub Desktop.
Attempt at monkeypatching casper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
casper.fetchTextArray = function fetchTextArray(selector) { | |
console.log(this); | |
var text = ''; | |
var elements = this.findAll(selector); | |
if (elements && elements.length) { | |
Array.prototype.forEach.call(elements, function _forEach(element) { | |
if(text === '') | |
text = element.textContent || element.innerText; | |
else | |
text = [text].push(element.textContent || element.innerText); | |
}); | |
} | |
return text; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TypeError: 'undefined' is not a function (evaluating 'this.findAll(selector)') in fetchTextArray