Google maps automation using appium


Any suggestions please how to achieve.

google maps is view inside your application?

Yes Aleksei.

The view is clustered view.

Scenario :
Assume Distributor A has 10 customers.
As soon as Distributor logged into application, he can able to see the all active customer’s locations in map where they are exactly.

Currently in cluster view, map showing 10 distributor(number(10) depends on active status of distributor) at one point as they are very nearer to each other. So if zoom in distributor can able to see the individual customer location point where he is exactly.

So now i have to automate below scenario:
1.After logged in need to get how many active customers showing in MAP.
Issue : In UI it is showing view like 4 RET or 2 RET, but when i spy using uiautomatorview i can able to spy the view but unable to get the number like 4 RET or 2 RET.

really do not want to start again with image recognition (i did it in previous project).
suggest first to try ask developers to add “title” or “snippet” value to markers.

when you tap on marker does any text appears?

So do you see a child “View” under the “Google Maps” View for each of your markers there? If so, ask your devs to fill out the “text” or “content-desc” for each with the text you need to retrieve. I had to ask my devs to do the same thing, and it makes automating so much more possible when they cooperate like that!

1 Like

Thanks for the reply Aleksei. I will ask the developers to help on this.

Yes text is appearing like tool tip. In the above snap shot, if I click on any image it will display the respective person role(Dstrirbutor/Retailer/Customer) like tool tip. But that text also I am not able to spy using UIAutomatorview.

@Brian_Watson and @Aleksei . Thanks for your valuable replies. I will take the help from DEV.

One more issue.
If I zoom in, cluster will become as individual markers based on some criteria. So in this Zoom in process few markers will not be visible on mobile screen until we move the map. In that case how to know in which direction ma need to move to locate other markers.

Or is there any way to find out the all markers which are present in map but not on mobile UI without moving the map.

if they all on screen you can get size of views under google map view otherwise move only

Hi Aleksei,

As you said once i get the size, i am double clicking on cluster in MAP to Zoom in, to see individual items. So in this process Cluster will change over to individual Markers and few are showing in mobile UI and few are moving from mobile UI view. So if we move the map (either left/right/up/down) then only we can able to see the other items. So how to know in which direction MAP should move to see the items after ZOOM in.

Is there any way to get the all views present on MAP, even though not able to see mobile UI.

no. Android shows only what is on screen.

Is there any workaround or trail and error methods to achieve that

maybe you can ask dev to add value to some element on screen for automation as number of found distributors

Like was mentioned, on Android, Appium only knows about what is on screen at that time. So your test case will have to know which way to scroll based on your test data and the actions you are telling it to perform.

On iOS, I know Appium can getPageSource() for things that are off screen for the app I test.

Hi @Brian_Watson, Thanks for the info.

Is there any way to get current marker location where exactly on MAP.

Can you use the coordinates that are displayed above in your screenshot?

Hi @Aleksei , @anil.jogireddy,
I am trying to automate the application having the HERE maps view.

My scenario is:

  1. I have to tap features on the map.
    Output: Feature highlights on the map and window having the feature details are displayed.

Dimension size = Global.mDriver.manage().window().getSize();
new TouchAction(Global.mDriver).press(230,225).waitAction(1000).release().perform();

Using the above code, i can able to tap on the object. But it is not working if pan the map or device resolution is changed.

Another problem is: Unable to inspect the features(objects) which are having on the map.

Could you please help with the solution?

@Krish.gottipati hi.

  1. last time i was need automate google maps - i had same issue with inspecting objects. looks like nothing we can do.
  2. with tap on needed object i used image tap. 3 years ago i wrote own Java class with using openCV. now Appium added such functionality. All you need is use it. Problem i met is every time map shown it showing objects a bit differently. I solved it by creating set of images that are correct. Looking one by one quickly and finding any of them. I any found i am just getting it location center and tap (Appium now has all this in Java client). You can check example in Appium code ->
1 Like

Here’s some useful info on how to perform gestures:

1 Like

Thanks for the help,
I will go through the above info and try to make it work. And i will let you know the outcome.

Our native app also use google maps sdk, and i can’t locate poi via appium inspector, how i can do this ?