microsoft / WinAppDriver

Windows Application Driver
MIT License
3.64k stars 1.4k forks source link

Robot Framework + Appium absolute XPATH issue #571

Open YouWhy opened 5 years ago

YouWhy commented 5 years ago

I am using Appium in Robot Framework to automate a Windows UWP application. In inspect.exe, the element I want to click is a Radio Button with name='QA' and the following are its ancestors:

Ancestors:  "FusionReg-MockUI" window
            "FusionReg-MockUI" window
            "Desktop 1" pane
           [ No Parent ]

I am using the following absolute xpath locator method to click it in Robot Framework script:

Click Element xpath=/Pane[@Name='Desktop${SPACE}1']/Window[@Name='FusionReg-MockUI']/Window[@Name='FusionReg-MockUI']/RadioButton[@Name='QA']

The above line fails with error 'Did not match any elements'.

however, if I use relative XPath it works!! Its very strange.

Click Element xpath=//RadioButton[@Name='QA']

I want to use absolute XPATH. What am I doing wrong?

I am not an expert in XPATH and I would really appreciate a solution, since I am doing some PoC work with Robot Framework + Appium + WinAppDriver for Windows App Automation.

Thanks.

karniemi commented 5 years ago

Just an note about your example - "//" is not "relative", but rather "recursive from current node": Click Element xpath=//RadioButton[@Name='QA']

...but sorry no idea why the absolute path is not working. Maybe the double ancestor: FusionReg-MockUI" window causes it somehow (https://github.com/Microsoft/WinAppDriver/issues/583 discusses something about "duplicate runtimeId", though I don't know if there's a bug report or proper explanation about the underlying problem in that).