I am not able to click on the sibling element
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"/>
How about this way? d(type="Button")[1].click()
@codeskyblue I will have to hardcode the index in this case. This will not be the better approach