Forum Discussion

rakeshkumar's avatar
2 years ago

Xpath Syntax for Mobile Application

How can i perform a click action using xpath like we do in eclipse.


For example:

In Eclipse-   driver.findElement(By.xpath("xpath")).click();


In testComplete- I have been trying 

var device = Mobile.Device();



It's not able to find the element and the script is failing. Can anyone help?


1 Reply

  • Kitt's avatar
    Regular Contributor

    [FindElementByXpath] is the correct method to use but I don't know what the object's actual xpath is. I would recommend using the Object Spy tool in TestComplete to see how TC is finding this object and what xpath reference is being used. You can also do a Record to Script to capture your onscreen actions and generate a script for you - and tweak as needed (TC doesn't always use the best xpath references so you may need to clean up the code to your liking).