I am testing my Android application using Appium framework. I have an android screen that doesn\'t have ids for its views (and I don\'t want to add...), so I thought using Xpath
Right now there's a couple nasty bugs with XPath on android that explain the behaviors you're seeing. They are scheduled to be fixed in the 1.3.1 release
Ideally, you could look for the resource-id of the android.widget.LinearLayout
parent of all 16 RelativeLayout
s and then do something like:
//android.widget.LinearLayout[@resource-id="foo"]/android.widget.RelativeLayout
Your verbose solution did not work because you gave one of the layouts a position of [2]
.
Here it is, fixed:
//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]/android.widget.ViewAnimator[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.ScrollView[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.RelativeLayout
.... please, please use the first solution.
I'm looking into a solution for your problem using UiAutomator
locator strategy, but no answers yet (because .fromChild()
and .fromParent()
seem to be broken)