Issue
The :has
and :contains
jQuery selectors for a UI element on the web page does not work in Power Automate Desktop. It does nothing and does not show an error in PAD. What could be wrong with the selector shown below?
div:has(strong:contains("2:00pm-6:00pm"))
<div data-test-component="StencilReactCard" data-testid="OpportunityCard-PTS1-2022-10-24T12:45:00Z-2022-10-24T17:15:00Z" role="button" tabindex="0" class="css-moukx6">
<div data-test-component="StencilReactCol" class="css-elwjao">
<div data-test-component="StencilReactRow" class="css-93w5zn">
<div data-test-component="StencilReactView" data-test-id="ShiftTimeSiteSkill" class="css-1cl9hwf">
<div data-test-component="StencilReactRow" class="css-7b15qy">
<div data-test-component="StencilText" class="css-5mrmps"><strong>2:00pm-6:00pm</strong> (4hrs)</div>
</div>
<div data-test-component="StencilReactRow" class="css-b9a2q3">
<div data-test-component="StencilText" data-test-id="ShiftTimeSiteSkill-site" class="css-kyen4s">CXO - PTS1</div>
</div>
<div data-test-component="StencilReactRow" class="css-b9a2q3">
<div data-test-component="StencilText" data-test-id="ShiftTimeSiteSkill-skill" class="css-kyen4s">CX Associate</div>
</div>
</div>
</div>
<div data-test-component="StencilReactCol" class="css-elwjao"></div>
</div>
<div data-test-component="StencilReactRow" class="css-1p30tql">
<div data-test-component="StencilReactView" data-test-id="StopPropagationContainer" class="css-1uk1gs8">
<button data-test-component="StencilReactButton" data-test-id="AddOpportunityModalButton" aria-label="Add shift button" type="button" class="e4s17lp0 css-1jwvbdk">
<div data-test-component="StencilReactRow" class="css-fpj0yv">Add shift</div>
</button>
</div>
</div>
</div>
Solution
Power Automate Desktop does support the :has
and :contains
jQuery selectors.
In the DOM tree that I posted in the original question, I needed to select the first div parent element shown on that DOM tree which contains the <strong>2:00pm-6:00pm</strong>
5 divs down the hierarchy and then select the button that this div element contains. The following worked with the Press button on web page
action:
div:has(> div > div > div > div > strong:contains('2:00pm-6:00pm')) button
Answered By - Raj Narayanan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.