I'm using java with test NG to automate my test cases in ubuntu with appium 1.6.3
so in place of inspector (when we run appium with mac) we only have uiautomatorviewer, how can i get the xpath from uiautomatorviewer ?
Is there any method that geenrate java code directly like appium inspector ?
Any xpath which generated by system (Appium Inspector or Browsers) is not recommended to use. The reason is it generates the hierarchy from top most parent to the element that you are finding including all the child-elements in between the parent and the actual element you are finding.
Your xpath should be as small as possible.
You can follow the simple Syntax of xpath as below:
//TAGNAME[@ATTRIBUTENAME='VALUE']
e. g. //INPUT[@id='username']
In case of Appium, just replace the tagname by class name and also id to resource-id, name to text etc.
Below two links are best tutorial for xpath: