Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (29.3k points)

Is there a way to capture errors occurring in the DOM in Selenium and probably flag the same as an error on the page?

To give a brief example, let's say I'm trying to bind an event on a non-existing HTML control, my browser throws an error saying:

element abcd not found in the console

Now, if I want the same error to fail my selenium tests and the message that is shown on the browser is shown as the error message.

Is it possible to do something like that?

1 Answer

0 votes
by (50.2k points)

Check the following script and paste on your page and then check in selenium for the JSError

<script type="text/javascript">





This will help you to get the same error message that you are desired off.

Browse Categories