The test I am creating is required to run a process then wait for it to finish and verify its results. My problem is that the process takes anywhere from 10 to 40 minutes so I need a way to have my test wait until this process is complete then continue on. The completion of the process is indicated by status notification changing from ‘in progress’ to ‘complete’. Any help would be greatly appreciated!
You you can use the following method:
In this example I will use the get the text if visible action but you can apply this logic using other actions too.
- I’m going to get the text from the element I want to wait for into a parameter
- I’m going to add a condition:
This condition will result in the step only running when the element text is not what we are expecting.
and because the parameter is empty it will start working from the first iteration.
- I’m going set a time for my intervals in this example I used every 1 minutes (60,000ms)
- And now I will make this step repeat every 1 minute up to 1 hour:
Our step will continue running as long as the text parameter is not equal to our expected result. once it’s equal it will skip the remaining iterations due to the condition.
It should look something like this:
This way you can dynamically wait for elements.
Note When the element is found the test continues instantly due to the condition.
If you want to dynamically wait less then few minutes you can simply use Adaptive Wait from test or step settings
This solution seemed to work well when I first implemented it but now, without changing anything about this part of the test, it will wait for a short time then continue even though the element I am getting text from hasn’t changed. Is there any reason this could be happening?
Thank you for your help!
EDIT: I think the issue is that in your example, the element is not visible while the step is waiting, this means that the wait feature will take the full ~30 seconds before trying again. In my case, the element is visible the entire time just with a different text. What I think is happening is that this allows the step to read the text, see that it is not equal to ‘X’, and read the text again immediately. With this in mind, can you think of any other solution or work around?
Please try to remove all the other locators on the element except the one using text, so this step won’t be able to self heal, it should fix your issue, take a look here:
When I get text from location it generates multiple locators
To remove the self healing:
And now delete all the locators that can find the element even when it’s not the text you are expecting for example here it’s the 2nd and 3rd locator:
The Self-Healing AI automatically heal our test to use the second / third locator, the problem is that these locator are disregarding textual changes.
Let me know if that fixed your issue.