How To Create Xpath With The Help Of Uiautomator For Android App?
Solution 1:
Ok so I recommend reading this article: http://www.w3schools.com/XPath/xpath_syntax.asp
But to give you an idea if you wanted to find a TextView
with the text "hello world" you could use this xpath:
//android.widget.TextView[@text='hello world']
//
means get any element
//android.widget.TextView
means get any element with the class android.Widget.TextView
//android.widget.TextView[@text='hello world']
means get any element of class
android.Widget.TextView
with attribute "text" equal to "hello world"
I hope this explanation helps. If you want a better understanding read that article
Solution 2:
You can access elements form their ID in R.class. For example:
EditTexteditText= (EditText) getSolo().getView(R.id.note);
You can find it in UIautomator at resource-id column. Also you can click on elements by text and etc.
If you are testing web app, you can emulate view in chrome and get x-path from there. Go to Developer tools -> emulation and select the device and agent that you need.
I was using Robotium framework
and if you don`t know how to build xpath, here is good tutorial http://www.w3schools.com/XPath/
Solution 3:
It is better to go for appium inspector (appium desktop app) if you are using appium mode, else if in selendroid mode use selendroid inspector - http://selendroid.io/inspector.html
Post a Comment for "How To Create Xpath With The Help Of Uiautomator For Android App?"