I am trying to make the robot click on a button on a website, but it is not clicking.
First, I have separated this click activity in a different sequence xaml file.
There is only one element found with this selector used in Click activity.
When I check the selector from Studio, it is valid in green.
When I run this sequence file by itself, it works. But when the actual execution is running from the beginning till end, it fails with Cannot find the UI element corresponding to this selector.
Sometimes, this button is visible, and sometimes it is not visible. But the button itself always exists and the selector won’t change whether the button is visible or invisible. So I am using Simulate Click so that the visibility won’t matter.
Can anyone please help me figure this out? I am at my wits end.
Are you sure that you compared the selectors between visible and invisible state of the button?
Is it possible that the button is not a button but some other html artifact such as a span when it’s not visible?
Did you check it Simulate Click factually works if the button is not visible? It may look like it’s working at design time, but not during the actual run.
Here is what happened. and this happened every time I tested it.
I first ran the robot and the button was invisible. Click activity was taking a lot of time, and it failed with timeout as expected. The error message was as described in #3 of my question.
Every time I ran it, the same problem happened. So I stopped the execution when the click is supposed to happen. And when I ran the sequence by itself, it ran no problem. Even when the button is invisible, it simulate-clicks it.
I don’t understand because the selector is exactly the same. It just doesn’t run when the robot is doing it, but it runs when I run the click activity by itself. The selector is also valid.
I tried to add a delay activity before the Click, but that didn’t solve the problem.
I would try running the program in debug mode with slow step and highlight elements enabled to see exactly where the program is failing. Sometimes an UI element not found error can be thrown because a previous part of the code is not navigating properly.
Put the click activity inside a Try catch. Reduce the timeout if needed. If the Robot fails to click the invisible button, handle that error in the Catch section.