Search code examples
seleniumselenium-webdrivertestng

How to handle dynamic error messages coming in an application


I am facing an issue while automating a web application at my work-place, and need helping advise to resolve the issue.

The application which I am testing is having a dynamic error popup screen which loads from the top whenever any error comes in the application. To be more clearer, let's say I am entering Username and password to login into application, and I took wrong username and password combination. Now, due to this a dynamic error drop down comes from the top. I am saying it dynamic because, as soon as I am trying to inspect the element, the error screen fades away. Now, due to this, I am not able to locate the element.

Sometimes, I got lucky and was able to inspect the element by right-clicking on that element. But then as soon as I reach to element tab, Error screen fades away, and not able to inspect the element.

So, I need help here to know how can I handle this dynamic error screen.

Any help will be appreciated. :-)


Solution

  • You can use devtools to pause:
    1. Open app in chrome
    2. Open devtools
    3. Go to Sources tab
    4. Trigger error and press F8 to pause
    5. Go to Elements tab and locate error html