http://www.perlmonks.org?node_id=11136044


in reply to Re^6: How do I get WWW::Mechanize::PhantomJS to wait until the JavaScript on the web page has finished executing? (update)
in thread How do I get WWW::Mechanize::PhantomJS to wait until the JavaScript on the web page has finished executing?

OK, so I think that's the problem. I added print $_->{message},"\n" for $mech->js_errors(); to my code, and I'm getting a mess of TypeError: undefined is not a function (evaluating ...) JavaScript errors that I don't see in any major web browser.

How very disappointing. I guess I'll have to try to get WWW::Mechanize::Firefox working...

Or maybe I can inject some polyfills? Seems others have encountered this sort of problem with PhantomJS:
https://github.com/tom-james-watson/phantomjs-polyfill
https://github.com/mathiasbynens/String.prototype.startsWith
I might try that first... I'm thinking the best way to do that is to copy ghostdriver/src/main.js and add the polyfills to that?
Well, no such luck with that. Adding the polyfills to the main.js didn't seem to help at all. I give up!