Selector valid but not clicking

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.

** ClickSubmitButton.xaml **
Try {
__AttachBrowser activity (Selector: <html title=‘BrowserName’) {
______Click activity (Selector:
________ <html title=‘BrowserName’ / >
________ <webctrl aaname=‘Submit’ parentid=’ * ’ tag=‘INPUT’ type=‘button’ / >
______)
}
catch (exception) {
__throw: "Error: " + exception.Message
}

Important points

  1. There is only one element found with this selector used in Click activity.
  2. When I check the selector from Studio, it is valid in green.
  3. 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.
  4. 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.

1 Like

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.

Hello @tomato25

Try removing parentid=’*’

keep aa name tag type and check

If the button is in invisible state, first you need to check that is it invisible or visible

to do that you can use get attribute activity to get the visible or invisible state

Hope this helps

Thanks

Ok.

You have to add logic to:

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.

To my surprise, the problem was not the Click activity!
It was the Attach Browser activity.

Apparently, <html title=‘BrowserName’ / > was not enough for some reason.
I just added another attribute to make it look like

<html title='BrowserName url='https://XXXXXXXXXXXXXXXXX * ’ />

and it started working.
Thank you everyone for help!

1 Like