When I set a selector , how can I use style attribute?

When I set a selector ,how can I use style attribute?

I want to distinguish elements that visibility is hidden or not.


<div id=“MyId” style=“visibility: hidden;”>

<div id=“MyId” >

But, When I use UiPath Explorer, I can not find “style”.

Please teach me how to realize it!


I assume that you are talking about Web Automation.

You could work something around with OuterHTML.

You can just surround the part of the text with two wildcards

<webctrl tag='IMG' outerhtml='*style=&quot;display: none;&quot;*' />

Note that you would rather need other selector properties such as tagName or ClassName, otherwise it will do the comparaison with all the HTML element on the document, which can be quite not efficient.



Did you try GetAttribute activity and pass “Visibility” for each element.(1 for visible 0 for Invisible)

1 Like

From my experience, either Visibility Attribute or IsVisible() Method on UiElement didn’t see to be reliable in case of HTML elements.

I would say they are rather meant for Desktop elements. In your example, it targets the WebBrowser Window.

The fact that he is looking for Style attribute makes me think that he wants to deal with HTML.


1 Like

Oh ok, not sure about that, so far i have used aastate for enabled/disabled and it works fine. I was thinking visibility applies to Asp.net controls where you set visible=true or false on the server side.

You could use style as well only if style attribute is assigned to element as inline (not as class)

Dear all

Thank you for answering!

I complete what I wanted to do using Florent_Salendres’s advice!!

But, I have a bit anxiety for using this idea.

In following situation, I think I mistakenly find element before loading finished.
Because outerhtml include inner element.

find element

<webctrl id=‘AsyncWait’ tag=‘DIV’ outerhtml=‘visibility: hidden;’/>

[HTML(During loading)]
<div id=“AsyncWait” style="visibility:visible; " >
<div id=“MyID” style=“visibility:hidden;”> </div>

[HTML(After loading)]
<div id=“AsyncWait” style="visibility:hidden; " > ←this is what I want to select
<div id=“MyID” style=“visibility:hidden;”> </div>

Do you know how can I resoleve this problem?

In the mean while try “getatrribute” activity and pass “style” with waitforready=complete.

Inject the output into your selector
<div id="AsyncWait" style="+strStyleVal.trim+" >

As @Florent_Salendres said include class or other unique attribute to make it more efficient.