2

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 for Windows App Automation.

Thanks.

utpal
  • 331
  • 5
  • 13
  • I changed the absoluate xpath and removed the /Pane portion and its working fine. Click Element xpath=/Window[@Name="FusionReg-MockUI"]/Window[@Name="FusionReg-MockUI"]/RadioButton[@Name="QA"] – utpal Jan 16 '19 at 03:32
  • 1
    using xpath is not recommended for appium. Please consider adding automation id in the elements. – Suban Dhyako Jan 16 '19 at 04:20

1 Answers1

3

I did some trial and error and I removed the 1st token of the above XPATH.

Changed /Pane[@Name='Desktop 1']/Window[@Name='FusionReg-MockUI']/Window[@Name='FusionReg-MockUI']/RadioButton[@Name='QA']

to

/Window[@Name='FusionReg-MockUI']/Window[@Name='FusionReg-MockUI']/RadioButton[@Name='QA']

and it worked.

utpal
  • 331
  • 5
  • 13