UI Explorer validating selector even though element does not exist

Hi all

I’ve had this problem a couple of times, but this time, I am unable to find a workaround, so I hope someone out there can help me find a solution.

I am running a process on a website, and sometimes I need to dismiss/accept a cookie notification.
I use the “Element exist” activity to check, whether the I need to click on the cookie banner before continuing The problem is, that UIPath validates my selector regardless to whether the banner exists or not.

I use the following selector:

<html app='chrome.exe' title='Erhverv'/>
<webctrl id='coiBannerHeadline' tag='H2' aaname='Vi bruger cookies  ' />

There are a number of unselected items as well - I have tried using almost every combination of items.

I have noted, that there are people that have had the same issue, but I have haven’t found a solution that worked for me so far.

I hope you can help me

Happy automation

Hi!

Your selectors are looking fine I think the problem with the element exist(If not appear)

Have you tried this?

After element exist->Use if condition (ElementFound=True)

in then block click accept cookies and in else block use same activities which you have used inside the then block!

Regards,
NaNi

it could be the case that the h2 tag is set to display:none by css. this can be done directly or on some parent elements.

In such a case the element still exists and the validation check will be sucessfully.

We can handle this, by retrieving the css property value and evaluating it. This can be done with the help of:

1 Like

Hi @lapet ,

i think you have to use element exist with the get attribute activity and look for the attribute called visibility. please refer the below thread for more guidance. thanks.

1 Like

Hi there @lapet,
I hope you are having a great day!

Most likely, the element still exists, but upon dismissal, it has it’s visibility set to false.
There are a few ways to handle this, you could:

  • Use a Get Attribute - Set to Visibility.
  • Use a Find Element - With Visibility set to True.

The above will allow you to check, not only that it exists, but whether it is visible on the screen.
Please let me know if you have any questions.
Thanks once again for your support,
Josh

3 Likes

Thank you very much

I ended up using the Get Attribute-activity using the “relativeVisibility”-attribute.

I tried some of the other proposed solutions, but this was the best match for me.
Thanks to everyone for your suggestions and especially for the solution

Happy automation everyone

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.