1

There is a calendar layout hierarchy. I'd like to locate each element in the ViewGroup. I can achieve it by hardcoding the Whole XPath, apparently it's quite un-efficient. Is there any better approach to do this?

Screenshot and the Hierarchy are given blow:

enter image description here

enter image description here

sakiM
  • 4,832
  • 5
  • 27
  • 33
Almett
  • 876
  • 2
  • 11
  • 34

1 Answers1

1

I've figured out a simple way myself:

Grid.androidDriver().findElementByXPath("//*[@resource-id='com.{path}:id/header_layout']/following::android.widget.LinearLayout[1]/descendant::android.widget.FrameLayout[@enabled='true']/android.widget.TextView[contains(@text,'"+date+"')]").click();
Almett
  • 876
  • 2
  • 11
  • 34