facebook-wda icon indicating copy to clipboard operation
facebook-wda copied to clipboard

I am not able to click on the sibling element

Open eguptax opened this issue 8 years ago • 2 comments

Here is the page source. I have a page where I want to click on the button of a particular text For e.g I want to click on the button next to the text Jhon. But both the text Jhon and Lisa has the same button id.

<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Jhon " name="Jhon " label="Jhon " enabled="true" visible="true" x="70" y="73" width="241" height="21"/>
<XCUIElementTypeButton type="XCUIElementTypeButton" name="companion checkbox checked" label="companion checkbox checked" enabled="true" visible="true" x="329" y="79" width="29" height="28"/> <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Lisa " name="Lisa " label="Lisa " enabled="true" visible="true" x="70" y="73" width="241" height="21"/>
<XCUIElementTypeButton type="XCUIElementTypeButton" name="companion checkbox checked" label="companion checkbox checked" enabled="true" visible="true" x="329" y="79" width="29" height="28"/>

eguptax avatar Mar 22 '18 00:03 eguptax

How about this way? d(type="Button")[1].click()

codeskyblue avatar Mar 23 '18 10:03 codeskyblue

@codeskyblue I will have to hardcode the index in this case. This will not be the better approach

eguptax avatar Mar 23 '18 15:03 eguptax