!!

Welcome to Selenium Webdriver Forum

As a web user you can read and search through forum content. Once you have registered and signed you can post topics, post replies, set up watch lists, modify forum settings, and use private messaging.

Author Topic: WebDriverJs error handling  (Read 655 times)

David Garcia Gomez

  • Web User
WebDriverJs error handling
« on: April 02, 2012, 09:31:11 PM »
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

  • Web User
Re: WebDriverJs error handling
« Reply #1 on: April 02, 2012, 09:31:29 PM »
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

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
342 Views
Last post February 21, 2012, 08:34:48 PM
by Wesley Chen
5 Replies
720 Views
Last post February 22, 2012, 06:14:11 PM
by Betsy
1 Replies
509 Views
Last post February 22, 2012, 06:47:22 PM
by Steve Hill
3 Replies
632 Views
Last post February 23, 2012, 08:54:01 PM
by Michael
6 Replies
872 Views
Last post April 15, 2012, 05:19:48 PM
by Rehan Iftikhar
3 Replies
825 Views
Last post July 04, 2012, 03:45:20 PM
by Balaji
0 Replies
887 Views
Last post October 30, 2012, 05:52:53 AM
by sriranjini

Review www.seleniumwebdriver.com on alexa.com