Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to catch browser exceptions for generic handler #1260

Closed
sahas- opened this issue Apr 20, 2016 · 1 comment
Closed

how to catch browser exceptions for generic handler #1260

sahas- opened this issue Apr 20, 2016 · 1 comment

Comments

@sahas-
Copy link

sahas- commented Apr 20, 2016

The problem

This is more of a guidance than an issue. I do have stack overflow question open for a while now and thought I'll ask here..sorry ..

I'm looking for guidance to handle browser exceptions in a central place instead of that being thrown out from the PageObjects classes. I'd like to be able to return a custom object with custom error message and stack trace from PageObject class back to the test and let the test handle, use the information for reporting etc..is it possible?

For example, I've my test like this

browser.setValue(_elements.searchbox, envSettings.searchTerm).catch((e)=>{
    let msg = {
           isSuccess: false,
           description: "failed while setting value in google search box",
           stacktrace: e
    }
   return Q.reject(msg);
})

when I run the test, I get this error

browser.setValue(...).catch is not a function

Whats the best way to bubble up all browser errors to a common handler?

Environment

  • WebdriverIO version: latest
  • Node.js version: system
  • Standalone mode or wdio testrunner: wdio
  • if wdio testrunner, running synchronous or asnychronous tests: synchronous
  • Additional wdio packages used (if applicable):
@christian-bromann
Copy link
Member

browser.setValue(...).catch is not a function no wonder, since your are running commands synchronously. You could loop over all commands the browser variable provides and overwrite them using try/catch.

use the information for reporting

What kind if reporting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants