How to check if text exists after each step


I sometimes get silent errors on the website that I am testing. The error is displayed in a dialog that can be skipped by clicking any element outside the dialog. Because the dialog is not preventing the next step to be executed, these errors could not be captured.

One way to handle this is to check whether the error text message exists on the page after each test step but adding this step after each test step would be time-consuming and inefficient. Test Listeners run before and after test case but not after each step.

Is there any way to check the existence of a text after each test step in a test case?



I seem to recall this feature/requirement was asked about before - something like @BeforeTestStep/@AfterTestStep. Perhaps @ThanhTo/@duyluong have some news?

The only way I can think of that is somewhat “cleaner” is to use a JavaScript setInterval() to monitor the page for the appearance of the dialog and dismiss it when found. You would need to add this ONCE per page per Test Case.

Let me know if that interests you …

I will need more information to target the correct area of screen to remove the dialog.


One way could be take screenshots after each step and read image text (OCR) to find out some known static failure texts, but this is quite hard for OS, but nowadays laptops have good cpu & mem capacity.
Not the best approach, but you can try :slight_smile:

Thank you Russ for your prompt answer. My intention is not to dismiss the dialog. I want to catch it rather than dismiss it. The dialog is dismissed if anywhere on the page is clicked in the next step of the case. This is not what I want because I want to know if this dialog ever appears because actually if the dialog is appeared, it means that there is a bug and I have to catch it.

1 Like

I think that would be time consuming even more than just adding an if case after each step manually :slight_smile:


i guess is not time consuming, only one class needed to check is there failure txt in screenshot, but needed java coding skill

The only way to do this right now is to write some kind of metaprogramming wrapper for WebUI et al. It would behave as broker, or “middle-man” that checks for the dialog before/after each step.

That would indeed be a tedious exercise. I would wait for @ThanhTo and @duyluong to respond.