Is there a way to click a Google Maps overlay with capybara-webkit? What about Capybara using Selenium? I want to test the content of the info window once the marker is selected. I also want to test that there are n markers on the page.
Asked
Active
Viewed 905 times
31
-
I'm looking for a way to do this too, have you been able to find a solution? – Erik J Apr 19 '13 at 16:42
-
No unfortunately not. I got nowhere with it. – trev9065 Apr 19 '13 at 20:59
-
seconded. we have an entire team trying to get this figured out – Kirka121 Dec 02 '14 at 16:06
2 Answers
0
To test that there are n markers on the page:
expect(find('.gmap_container')['data-markers'].split('},{').count).to eq(n)

Marian Mosley
- 31
- 1
- 2
-
I am no longer working on this can anyone else confirm that this works and I will accept this answer? – trev9065 Mar 27 '15 at 11:51
-
Didn't work for me. tried `find('.gmap_container')` and it was not found. Could be something on my end though. – Gustavo Matias Apr 25 '16 at 20:30
0
This can be done, but requires a change to how you create your markers. You must instruct them to render as images rather than canvas elements:
new google.maps.Marker({
position: latLng,
animation: google.maps.Animation.DROP,
name: business.get('name'),
id: business.get('id'),
optimized: false, // <-- this is the stuff
title: business.get('name')
});
Then in your test, you can find('div[title="Business\ Title"]').click
If possible, you might want to consider doing this just for a test environment, but that's up to you and your needs.
Credit: http://blog.mojotech.com/selecting-google-maps-v3-markers-with-selenium-or-jquery/
Hope this helps!

DanOlson
- 1