Taro
(Taro)
May 24, 2017, 8:50am
1
When I set a selector ,how can I use style attribute?
I want to distinguish elements that visibility is hidden or not.
[Example:A]
<div id=“MyId” style=“visibility: hidden;”>
[Example:B]
<div id=“MyId” >
But, When I use UiPath Explorer, I can not find “style”.
Please teach me how to realize it!
Hello,
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="display: none;"*' />
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.
Cheers.
3 Likes
vvaidya
(Vinay Vaidya)
May 24, 2017, 6:31pm
3
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.
Cheers
1 Like
vvaidya
(Vinay Vaidya)
May 24, 2017, 7:48pm
5
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)
Taro
(Taro)
May 25, 2017, 1:58am
6
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.
[Activity]
find element
[Selector]
<webctrl id=‘AsyncWait’ tag=‘DIV’ outerhtml=‘visibility: hidden; ’/>
[HTML(During loading)]
<div id=“AsyncWait” style="visibility:visible; " >
<div id=“MyID” style=“visibility:hidden;”> </div>
</div>
↓
[HTML(After loading)]
<div id=“AsyncWait” style="visibility:hidden; " > ←this is what I want to select
<div id=“MyID” style=“visibility:hidden;”> </div>
</div>
Do you know how can I resoleve this problem?
vvaidya
(Vinay Vaidya)
May 25, 2017, 2:27am
7
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.