How to test maps ( OpenLayers, Google Maps, Leaflet ...) with Behat

632 views
Skip to first unread message

Frederic Marand

unread,
Aug 15, 2013, 4:36:36 AM8/15/13
to be...@googlegroups.com
Hello,

I am writing acceptance tests for a Drupal project, and some of the touchy parts of the site involve maps, currently OpenLayers, but doable with anything else if it is simpler to test: this is basic mapping, not a real GIS application.

Search engines appear exceptionally unhelpful for this combined request, suggesting that either this is something no one ever did (?), or that is was so simple that it didn't warrant any question (??).

Any suggestions ? I suppose this will imply using a browser-based agent behind Mink, like Selenium, Sahi, or Zombie (I saw Mink has drivers for all three in addition to Goutte, which is unapplicable here since it doesn't do JS).

Andrew Larcombe

unread,
Aug 16, 2013, 7:07:15 AM8/16/13
to be...@googlegroups.com
Hi Frederic, 

What do your stories look like? What are you actually trying to test? One option might be to use evaluateScript to do things such as eg checking bounding boxes?


Andrew

FGM at GMail

unread,
Aug 16, 2013, 10:42:30 AM8/16/13
to be...@googlegroups.com
Hi Andrew, thanks for looking into it.

There are a number of cases, the stories/scenarios can be written as
needed as long as they represent the need, there is no constraint at
that level. A typical case could look like this:

- given I have created "Park" and "Has bisons" categories
- and I create some content localized at "Central Park, NY" and tag it
with "Park", "Has bisons"
- when I go to its page
- I should see a map in region sidebar
- and the map should be centered at "Central Park, NY"
- and its extent should be 42 km

- given I have created "Park" and "Has bisons" categories
- and I create some content localized at "Central Park, NY" and tag it
with "Park", "Has bisons"
- when I go to the "USA map" page
- then the overlay control widget should include "Park" and "Has
bisons" overlays
- and I should see a marker at "Central Park, NY"

- given I have created "Park" and "Has bisons" categories
- and I create some content localized at "Central Park, NY" and tag it
with "Park", "Has bisons"
- when I go to the "USA map" page
- and I uncheck the "Has bisons" overlay
- then I should see a marker at "Central Park, NY"
- and hovering over "Central Park, NY" should display a popup labeled
"Central Park: Park, Has bisons""

- given I have created "Park" and "Has bisons" categories
- and I create some content localized at "Central Park, NY" and tag it
with "Park", "Has bisons"
- when I go to the "USA map" page
- and I uncheck the "Has bisons" and "Park" overlays
- then I should not see a marker at "Central Park, NY"

=> problem 1 met: the map would display on webkit browsers, not on the
others. This was a CSS bug, all page content was correct, but this
causes the bitmap layer to be gray instead of looking like a map
=> problem 2 met: the extent would be incorrect (world map instead of
system-configured extent)
=> problem 3 met: the map would not be loaded at all (daily geocoding
limit had been reached)
=> problem 4 met: relating something on a step (I create some content)
to something on another step in the same scenario (I go to its page)

An unrelated problem is that this site has several base urls, and uses
per-language paths (like <country>.example.com/<lang>/my-map), and
tests will need to check that non-language-neutral cross-site content
appears only on the sites where it is supposed to appear, and only for
the appropriate languages, but I think I can handle it one way or
another. I'm more stuck with the purely visual parts of testing this
involves

2013/8/16 Andrew Larcombe <and...@andrewlarcombe.co.uk>:
> --
> You received this message because you are subscribed to the Google Groups
> "Behat" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to behat+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Andrew Larcombe

unread,
Oct 8, 2013, 6:53:42 AM10/8/13
to be...@googlegroups.com
Hi,

The approach I'd take is to encapsulate these steps into a 'Map' element

- and the map should be centered at "Central Park, NY" 
- and its extent should be 42 km 

writing a couple of custom methods:
->getCentre()
->getExtent()

which use a js call to query the map library (OpenLayers/Leaflet etc) as appropriate. You'd probably need a dictionary in Behat that converts "Central Park, NY" to a lat-long, and you might need to round the extent to the nearest km.

Hope that helps!

FGM at GMail

unread,
Oct 8, 2013, 3:55:31 PM10/8/13
to be...@googlegroups.com
Thanks for the suggestion. AIUI, however, this would not catch the
case of an apparently correctly working map with does not actually
display if there is some CSS problem causing the tiles to be hidden or
display:none, would it ?

2013/10/8 Andrew Larcombe <and...@andrewlarcombe.co.uk>:
Reply all
Reply to author
Forward
0 new messages