-1

I'm new to appium and I'm just stuck at this particular place for so long and none of the solutions are working for me anymore.Even a slightest nudge at the right direction will be really appreciated.

I'm trying to automate an app which looks like below.enter image description here

I want to traverse in the first horizontal banner(Ex:-Recently Added Tv).Play all the videos in that banner and then proceed with the second banner(Recently Added Movies) the same way.

I'm finding issue with find the locators for these elements.Following is the structure for the Android App.

<Android App>    
      <First Horizontal Tab-Recently Added TV>
      [resource-id="A",class="B",index=0]
                    <Child Element-Video File>
                          [resource-id="A",class="B",index=0]
                    <Child Element-Video File>
                          [resource-id="A",class="B",index=1]
                    <Child Element-Video File>
                          [resource-id="A",class="B",index=2]  
                    <Child Element-Video File>
                          [resource-id="A",class="B",index=3]          

      <First Horizontal Tab-Recently Added Movies>
      [resource-id="A",class="B",index=0]

                    <Child Element-Video File>
                          [resource-id="A",class="B",index=0]
                    <Child Element-Video File>
                          [resource-id="A",class="B",index=1]
                    <Child Element-Video File>
                          [resource-id="A",class="B",index=2]  
                    <Child Element-Video File>
                          [resource-id="A",class="B",index=3]  

Both the horizontal bars are having all the same parameters except the header.Also the child elements are having common parameters between the slide bars.

I wanted to get the total count of videos in first slider bar,scroll it and get the video count in that row till end.And then start playing videos from home page,one by one.

But I'm getting double count as both the bars are having all common names for elements.

Please tell me how to get the desired result or if it's even possible to do so.

lionxlamb
  • 391
  • 5
  • 14

1 Answers1

0

You could try to use xpath locators to get all video files.

Maybe the UIAutomatorViewer is helpfull too. It shows all diferent kinds of locators and you can save the underlying XML. With tools like XMLSpy or other online tools you can then test your xpath locator.

Remember to stop the appium server before using UIAutomatorViewer, because else it won't work.

AndiCover
  • 1,724
  • 3
  • 17
  • 38
  • @AndiCover..thsnk you for helping.I'm using UIAutomator2 and using xpath to get element locators.But in this particular case,there is no unique for the elements.So it's giving list of all the video files in all the horizontal bars .Appium inspector is also unable to get any xpath,that works. – lionxlamb Feb 24 '19 at 16:22
  • `//driver.findElement(By.xpath("//android.support.v7.widget.RecyclerView[@resource-id='com.nova:id/horizontal_recycler' and @index='1']"));` The above xpath works for me,but gives me elements of the second slider as well,as both have same resource-id and index number and class. – lionxlamb Feb 24 '19 at 23:03
  • I'm able to locate the element using the xpath I'm getting from appium inspector.The xpath goes like this; `driver.findElement(By.xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v4.widget.DrawerLayout/android.widget.RelativeLayout/android.support.v4.view.ViewPager/android.widget.RelativeLayout/android.widget.ScrollView/android.widget.RelativeLayout/android.support.v7.widget.RecyclerView/android.widget.LinearLayout[1]/android.support.v7.widget.RecyclerView"))` – lionxlamb Feb 24 '19 at 23:04
  • Why don't you iterate over all elements? `for(WebElement element : driver.findElements(By.xpath("YOUR_LOCATOR"))){` – AndiCover Feb 25 '19 at 05:40
  • Thank you.I'll surely try this.Meanwhile I tried this to get the child-element. `By.xpath("//*android.widget.LinearLayout[@index='0']/child::*")` considering "/*android.widget.LinearLayout[@index='0']/" as the xpath of the parent bar but it fails to fetch the child elements. – lionxlamb Feb 26 '19 at 06:58