Lack of Unique Information on UI Automator Viewer

Guys

As per the screen shot, I am trying to automate opening BBC radio using S5 android version 4.4.2. However, I am facing some issue. I think the issue is that there is no information unique enough to identify this item/object in the node details. I tried to write different code to click on the BBC WORLD SERVICE, but still no luck, please see the code below and advise where I am going wrong:

dr.findElement(By.id(“tunein.player:id/mini_player_container”)).click();

dr.findElement(MobileBy.AndroidUIAutomator(“new UiSelector().descriptionContains(“BBC””)).click();

dr.findElement(By.xpath("//android.widget.FrameLayout[@index=‘6’]")).click();

dr.findElement(By.xpath("//android.widget.FrameLayout[@bounds=’[378,492][678,792]’]")).click();

dr.findElement(By.xpath("//android.widget.FrameLayout[378,492][678,792]")).click();

Thanks in advance
T.K

I forgot to mention that the resource id is not unique, it is uniform for all objects on the left side, same thing with the index, for example, the LIVE RADIO object has index 6 as well.

T.K

Does the layout of the screen ever change?

Perhaps you could search for multiple elements based on resource-id or xpath, knowing (hoping?) that the order returned by Appium will remain constant.

Hi Willosser

Thanks for getting back to me! Yes, the layout does change depending on where you click. I hope I am not misunderstanding you, the issue here is that the resource id which was meant to be unique is not unique, if it was life would have been much simpler. all items have exactly the same resource id, if I pass the resource id, I have not tested it, but it will most likely open the NRK radio station as that is probably the first one it finds or it will not open anything at all. Worth trying and see what I get.

I was hoping one of the below xpath would work as they uniquely identify the item.

dr.findElement(By.xpath("//android.widget.FrameLayout[378,492][678,792]’")).click();
dr.findElement(By.xpath("//android.widget.FrameLayout[@bounds=’[378,492][678,792]’]")).click();

If the xpath did not work, at least the below work
dr.findElement(MobileBy.AndroidUIAutomator(“new UiSelector().descriptionContains(“BBC””)).click();

Please feel free give advise/comments

T.K

Hi T.K.

I understand the problem with the lack of unique resource ids. If you can’t be guaranteed of the location or order of the images, I don’t see how you can use xpath and specify the x-y coordinates. If the description of the element is present, and you aren’t worried about testing in other languages, that appears to be the best option.

Hi Willosser

In my opinion, I do not find UI Automator viewer complete enough to enable full automation as you find id on some items but not on others. So, I am trying to find alternative, Appium/Selendroid inspector have been suggested. Appium inspector does not work on windows, since I am using windows 7, the only option left is Selendroid inspector. In order to use Selendroid inspector, I think one has to integrate it with Appium. If anyone knows the steps, how to integrate Selendroid inspector with Appium, please let me know the steps.

You also suggested to use another language, what language do you have in mind?

Thanks,
T.K

you can not attach selendroid inspector with appium. the reason behind is that Appium inspector uses google’s own Uiautomator instrumentation. while selendroid uses its own. so one thing you can do.
you can record script using selendroid inspector which is bundled with selendroid jar.

and in your main script you need to change capabilities “AutomationName” to “Selendroid”, which enables your script to run in selendroid mode.

Thanks,
Priyank Shah

Thanks Priyank and Willosser for your inputs!

I will give selendroid a try. I have one additional question which is a little bit out of topic. I know for sure that Appium supports Android and IOS platform.

So far I have been automating on Android phone. However, my main aim/wish is the automate it on windows mobile for native apps.

I have read some stuff about this on some forums, please see the below links:
https://groups.google.com/forum/#!topic/appium-discuss/wmgRPTtZR_s

if I am not mistaken, Windows mobile should also be integrated with Appium pretty much like Selendroid .

Please advise if Windows mobile can already be integrated with Appium? it if can’t yet, how long do you think it will take to have Windows mobile platform supported by Appium?

Thanks in Advance!

T.K