Skip to content

Instantly share code, notes, and snippets.

@Meekohi
Created April 10, 2013 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Meekohi/5357689 to your computer and use it in GitHub Desktop.
Save Meekohi/5357689 to your computer and use it in GitHub Desktop.
Attempt at monkeypatching casper
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;
};
@Meekohi
Copy link
Author

Meekohi commented Apr 10, 2013

TypeError: 'undefined' is not a function (evaluating 'this.findAll(selector)') in fetchTextArray

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment