Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is automated testing of Open Layers possible?

I am attempting to use selenium to test OpenLayers-2.13.1 functionality. I am having problems with mouse clicks, mouse downs etc.... I found a couple of out-dated posts with similar problems but their resolution didn't help me. Does anyone know of any software that can be automated to properly test Open Layers.

http://lists.osgeo.org/pipermail/openlayers-users/2012-November/026791.html

like image 992
John Avatar asked Sep 30 '22 18:09

John


1 Answers

We have had some success in using Selenium WebdriverIO in running automated tests of our mapping.

The way we address map click throughs is by exposing a function from the map script from which we can get the pixel location of a feature on the map.

function pixelOfFeature (id) {
    return map.getPixelFromCoordinate(...coordinate of feature...)
}

Then in our test script, once on our loaded mapping page, we query the map object for the pixel of the feature we want to click, and using webdriverio we can then move the mouse to the pixel value within the map css selector, and then perform a .buttonPress().

var client = webdriverio.remote(options)

client.moveToObject('.map', pixel[0], pixel[1]).then(function(){
    client.buttonPress(0).then(callback)
})

http://webdriver.io/api/action/moveToObject.html

http://webdriver.io/api/protocol/buttonPress.html

We use ol3 however the same approach could be taken for openlayers 2

It's probably too late for the OP but hopefully this might help someone get started.

like image 171
Tedd Avatar answered Oct 13 '22 01:10

Tedd