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

Create graceful exception handling when an unexpected error on the page appears #8

Open
kgress opened this issue Mar 22, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@kgress
Copy link
Contributor

kgress commented Mar 22, 2019

Summary:

Currently, when a test fails due to an unexpected error on the UI, the test will fail in a couple of ways:

  • NoSuchElementException
  • WebDriverException

Instead of having these errors at the top level by default, we should first check to see if there are any errors displayed on the UI first and report those prior to reporting an element couldn't be found or if there's a problem with the WebDriver.

An example failure:

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"[data-qa='some-link']"}
  (Session info: chrome=71.0.3578.80)
  (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
...

This error appeared during the Navigation class so we can assume that there is a problem with navigation; but, we don't know the exact reason why there was a problem with navigation. We must first look at the sauce labs dashboard to view the video from the test run. In this example above, we found that there was a problem with the UI and it displayed a generic error message; therefore, the element we were looking for could not be found.

Not being able to find an element on a page, as it's doing now, infers that the automation did not encounter any issues with the UI and that it simply wasn't able to find the element; which is not entirely the most truthful case.

As a bonus to this, if we could also report any errors in the console, this would help out tremendously for debugging purposes.

Risk/other

I'm not sure there's a one sized fits all solution for this. There are a lot of different potential cases for where we would like to see this kind of behavior.

One potential thing to consider is figuring out a way that we can generalize this to apply to multiple element types. Thankfully, the way our strongly typed elements are set up right now, they all inherit off of a parent class.

I think, in general, it is possible to just check the dom for any instances of an attribute on an element of "is-error". Maybe we can check the console?

A/C:

  • Scaffold should be able to report UI level errors as a first level form of error reporting
  • If there's no problems with the UI, Scaffold should report the next level down - e.g. NoSuchElementException or WebDriverException
@kgress kgress added the enhancement New feature or request label Mar 22, 2019
@kgress
Copy link
Contributor Author

kgress commented Apr 9, 2019

Found a link that talks about some console logging: https://stackoverflow.com/questions/25431380/capturing-browser-logs-with-selenium-webdriver-using-java

@kgress
Copy link
Contributor Author

kgress commented Apr 15, 2019

I'm splitting the console log reporting into a separate ticket as it will solve the immediate issue for our testing. We should still investigate the inclusion of looking for other potential errors on the page, like a network call that returned a 503. The ticket to reflect this work is #17 .

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

No branches or pull requests

1 participant