openatx / facebook-wda

Facebook WebDriverAgent Python Client Library (not official)
MIT License
1.72k stars 266 forks source link

I am not able to click on the sibling element #47

Open eguptax opened 6 years ago

eguptax commented 6 years ago

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\"\/>

codeskyblue commented 6 years ago

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

eguptax commented 6 years ago

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