I am trying to automate an app . I have found few of the elements using xpath. In marshmallow devices, the elements are not able to find using xpath which is working fine in kitkat/lollipop devices. For example in KitKat/lollipop the xpath contains view; the same xpath in marshmallow instead of view it is taking as Viewgroup. How to provide the same xpath for all the version?
The following are the xpath of the same element in kitkat and marshmallow :
In kitkat: xPath is //android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.support.v4.widget.DrawerLayout[1]/android.view.View[1]/android.view.View[2]/android.widget.ScrollView[1]/android.view.View[1]/android.widget.ScrollView[1]/android.view.View[1]/android.view.View[1]
In Marshmallow: (for same element xpath is as below) //android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view.ViewGroup[1]/android.view.ViewGroup[1]/android.view.ViewGroup[1]/android.view.ViewGroup[1]/android.view.ViewGroup[1]/android.support.v4.widget.DrawerLayout[1]/android.view.ViewGroup[1]/android.view.ViewGroup[2]/android.widget.ScrollView[1]/android.view.ViewGroup[1]/android.widget.ScrollView[1]/android.view.ViewGroup[1]/android.view.ViewGroup[1]