How to deal with google maps using Webdriver

8,809 views
Skip to first unread message

chaitanya

unread,
Sep 16, 2013, 4:35:18 AM9/16/13
to seleniu...@googlegroups.com
Hi friends,

I need to automate an application based on google map api.The scenario is as follows.
1.Type the location in address bar.
2.Locate the region(the background colour) in which that location is surrounded by.

e.g A Lake location has blue colour as its background.

I am trying with sikuli-webdriver,but i guess it doesnt retrieve the location properties.

Kindly give me some insights into this scenario..



Kumar.S.K

unread,
Sep 16, 2013, 4:58:36 AM9/16/13
to seleniu...@googlegroups.com

Plz try the below cases, iff possible..!

1) Try to compare the screens, by taking screenshots before and after case.
2) Make one position fixed, and then using x-axis and y-axis attributes, we can compare the location.

NOTE:- I've done in my project, similar to this. So, I suggested..! I'm not sure, about your application.

Mark Collin

unread,
Sep 17, 2013, 3:48:45 AM9/17/13
to seleniu...@googlegroups.com
I guess the first question is why are your tests checking images that Google gives you.  What are you going to do if they change (They will at some point)? 

If the answer is ignore it and change your test, you have just proved that your test is worthless...
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd7c4f7f-0641-40d3-adee-1188bc024485%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

chaitanya krishna

unread,
Sep 17, 2013, 3:58:11 AM9/17/13
to seleniu...@googlegroups.com
Hi mark,

Sorry i havent mentioned that i have to test the overlays i.e polygons,rectangles on top of google map api.
I just need to identify the colour of it....
I have observed this overlays are svg objects..


--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/BJ79071Jzw0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

Mark Collin

unread,
Sep 17, 2013, 7:08:56 AM9/17/13
to seleniu...@googlegroups.com
In that case the best thing to do would be to get the devs to write a hook into the google maps API that will return a list of polygons and their associated information (It's not hard for them to do).  You can then use a JavascriptExecutor to query the page and get the information you need for your tests.

JavascriptExecutor is your friend when testing overlays on Google maps.

chaitanya krishna

unread,
Sep 17, 2013, 7:19:34 AM9/17/13
to seleniu...@googlegroups.com
Hi Mark,

But i havenot observed any attribute saying color of the overlay shape in the DOM structure...

the overlay shape is embedded in the canvas object as 
<canvas style="position: absolute; left: -760px; top: 62px; z-index: 1000;" width="2020px" height="118px"></canvas>
There is no attribute called color is defined...it is defined only in the js file params as follows

    function initialize() {
      if (GBrowserIsCompatible()) {


        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(45.828799,-105.292969), 2);
        var polyOptions = {geodesic:true};
        var polyline = new GPolyline([
          new GLatLng(40.65642, -73.7883),
          new GLatLng(61.1699849, -149.944496)
     ], "#ff0000", 10, 1, polyOptions);
        map.addOverlay(polyline);
        map.addOverlay(createLengthMarker(new GLatLng(45.828799,-105.292969)));
      }
    }  
    
So,Can there be anyway to retrieve this color Mark?


Mark Collin

unread,
Sep 17, 2013, 7:43:25 AM9/17/13
to seleniu...@googlegroups.com
It won't be in the DOM, it will be hidden away in the JavaScript code which is why you need a test hook to access the Google Maps API in the JavaScript code.  You are looking for a test hook that will give you access to https://developers.google.com/maps/documentation/javascript/overlays#Polygons.  You will then be able to examine the polygon objects and pull out information like colour/location/etc.

It's not easy and will require dev support.

sunny sachdeva

unread,
Sep 17, 2013, 1:14:10 PM9/17/13
to seleniu...@googlegroups.com
Hi Chaitanya,

seems like i am also working on similar issue, i have a navigational map (its not Google Map but bing map) and i need to draw a polygon based on user input.

in my cases sikuli worked flaw less. try sikuli it will work.

Thanks
Sunny

chaitanya krishna

unread,
Sep 18, 2013, 1:12:44 AM9/18/13
to seleniu...@googlegroups.com
Hi sunny,

Glad u r also working on the issue similar like mine... . I have a few questions sunny...

1.Can sikuli api be used to draw the polygon...? I guess that can be done only by using Google Overlay APi rt?

Can you share your code in the group sunny which u have done using sikuli.....that will be very helpful to me...


balu selenium

unread,
Dec 3, 2015, 10:14:05 AM12/3/15
to Selenium Users


Hi,

nice to see this kind of post, request you to send me the code for following scenario.

In my application, Maps (developed with leaflet.js framework) is there, on that maps i see icons but when inspected they are not images. for my automation
testcase, i have to select the icon to move forward. please have a look at attached pic below and guide me the code/solution.
the dom is as follows.


Auto Generated Inline Image 1

Angalo Simon

unread,
May 25, 2017, 12:39:19 AM5/25/17
to Selenium Users
Hi All,

I need to automate A Map. I jest need the automation script for the following scenario.

         1 )   Scroll down to the map and find the location pin.
          2 )   Click on each pin and a pop up would appear
          3 )   Retrieve all the details displayed in the popup.  

Please help me with trying it on Google MAPs.

Thanks,
Angalo


On Monday, 16 September 2013 14:05:18 UTC+5:30, chaitanya wrote:

Eduardo de Paula

unread,
Dec 14, 2017, 1:16:14 PM12/14/17
to Selenium Users
@Angalo, I need to the same thing here!

Did u find a way to automate your test cases?

Angalo Simon

unread,
Dec 14, 2017, 10:12:47 PM12/14/17
to Selenium Users
No dude... Need a research on that... Please be in contact... Please drop a mail to angaj...@gmail.com when u found out a solution for this...

Surabhi Dixit

unread,
Apr 25, 2019, 4:14:15 PM4/25/19
to Selenium Users
Hello Angalo,

I am looking for same scenario with Esri maps, have you got the solution? 
I have multiple scenarios to automate:
1) Draw a polygon
2) Validate the polygon: I think we can use compare image for this
3) Use pushpin to view some properties
4) Use pushpin to locate addresses and then validate the path drawn


Regards,
Surabhi

Manish Sewlikar

unread,
Apr 26, 2019, 1:07:12 AM4/26/19
to seleniu...@googlegroups.com
Selenium is not useful map as per my experience in my project may check with for expert opinion. 

Manish Sewlikar

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

raswitha koripalli

unread,
Apr 17, 2020, 11:28:52 AM4/17/20
to Selenium Users
Hi Angalo,
Did you find the solution for this. Please let me know.
Thanks
Reply all
Reply to author
Forward
0 new messages