WebDriverJs error handling

138 views
Skip to first unread message

David Garcia Gomez

unread,
Dec 14, 2011, 2:12:56 PM12/14/11
to Selenium Users
Hello,
Is there a way to catch errors in webdriverjs when the driver instance
is created?
In the example:
var driver = new webdriver.Builder().
usingServer('http://localhost:4444/wd/hub').
withCapabilities({
'browserName': 'chrome',
'version': '',
'platform': 'ANY',
'javascriptEnabled': true
}).
build();

If there is something wrong with my server, or my desired capabilities
are not supported it will just throw and exception.
It would be nice if we can pass an error handler function to the build
metod so we could do something about it or exit nicely.

Also if I have multiple commands like;

driver.click().then(null, errHandler);
....
driver.something().then(null, errHandler);

Is there any way to add a default errHandler that applies for every
command so you dont have to add it to every single command? Maybe in
the builder something like withErrorHandler(errHandlerFunction)

Is there any better to do this?

Thanks!

/david

Jason Leyba

unread,
Dec 29, 2011, 2:11:36 PM12/29/11
to seleniu...@googlegroups.com
All unhandled rejected promises are reported to the webdriver.promise.Application.  The app will fire an "uncaughtException" event if you have a listener registered.  Otherwise, it will just re-throw it to the global error handler.

webdriver.promise.Application.
    getInstance().
    on('uncaughtException', function(e) {
        console.error('There was an unhandled exception! ' + e);
    });

-- Jason
Reply all
Reply to author
Forward
0 new messages