MinkZombieDriver
MinkZombieDriver copied to clipboard
Detect javascript errors when visiting a new web page
This makes it possible to see what is going on if you visit a web page and it has javascript errors, or the page fails to load for other reasons (f.ex. the server might be down).
Without this fix, after you visit you just get http code 0 instead of 200, and you will not know what is going on.
@aik099 Anything I can do to get this PR accepted?
I guess you can show error output example of your code compared to what it would be for @stof recommended approach. That should help @stof decide if your approach would be better.
Here is an example of what happens when the php server is runnung at the not expected port. First with my fix:
And I am on the web page "view quote" with id "300" # WebContext::iAmOnTheWebPageWithId()
Error when loading page http://localhost:8383/quote/300: "TypeError: connect ECONNREFUSED 127.0.0.1:8383\n at /usr/lib/node_modules/zombie/lib/pipeline.js:89:15\n at tryCatcher (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/util.js:16:23)\n at Promise._settlePromiseFromHandler (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/promise.js:512:31)\n at Promise._settlePromise (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/promise.js:569:18)\n at Promise._settlePromise0 (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/promise.js:614:10)\n at Promise._settlePromises (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/promise.js:689:18)\n at Async._drainQueue (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/async.js:133:16)\n at Async._drainQueues (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/async.js:143:10)\n at Immediate.Async.drainQueues (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/async.js:17:14)\n at runCallback (timers.js:651:20)\n at tryOnImmediate (timers.js:624:5)\n at processImmediate [as _immediateCallback] (timers.js:596:5)" (Behat\Mink\Exception\DriverException)
Here is how it will look if we do it the way @stof suggested:
And I am on the web page "view quote" with id "300" # WebContext::iAmOnTheWebPageWithId()
Error "TypeError: connect ECONNREFUSED 127.0.0.1:8383
at /usr/lib/node_modules/zombie/lib/pipeline.js:89:15
at tryCatcher (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/promise.js:689:18)
at Async._drainQueue (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/usr/lib/node_modules/zombie/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:651:20)
at tryOnImmediate (timers.js:624:5)
at processImmediate [as _immediateCallback] (timers.js:596:5)" while executing code: pointers = [];
browser.visit("http://localhost:8383/quote/300", function (err) {
if (err) {
stream.end('CAUGHT_ERROR:' + JSON.stringify(err.stack));
} else {
stream.end();
}
}); (Behat\Mink\Exception\DriverException)
You see that the second error message has no information the url of that zombie tried to connect to when the error happened.