How to test OpenLayers app with Selenium?
Hi.
I know this is and oldie, and I apologize for that. But I still haven't found a solution to this.
I have recently tried to test my OpenLayers-based app with Selenium. But when I click on the map, it doesn't detect the click in Selenium. I have searched all over the Internet. Some people say it is a bug from Selenium, other claim to have found a workaround.
I have tried all these solutions and I am getting no results. The clicks still don't work.
http://osgeo-org.1560.x6.nabble.com/Testing-with-selenium-IDE-td5015680.html
http://stackoverflow.com/questions/13712252/selenium-ide-testing-on-mapsopen-layers
http://comments.gmane.org/gmane.comp.gis.openlayers.user/18125
Could you please explain it better? Or maybe show an example?
Thanks
João Rodrigues
PS: I am new to Selenium, so it might be a bit more difficult for me to understand it.
Clicking on the canvas and not some parent element did the trick for me (assuming you're using canvas as renderer)
I'm running into this same issue. I have an OpenLayers map on my page and when I use Protractor/Selenium commands to interact with the page then the browser clicks do not register on that map in that my interaction event handlers are not fired. Following recommendation from @lbesson above, I tried to use the 'canvas' element as the basis for the Protractor browser actions, but that does not help.
Here's my code. The 'vertex tool' is a custom interaction that inserts a certain custom 'vertex' feature into a layer on the map when the user clicks. I am trying to do four clicks in a row to create four of these vertices.
`
var map_canvas = element(by.css('canvas'));
// activate the vertex tool
browser.actions().sendKeys('v').perform();
browser.actions()
.mouseMove(map_canvas, {x: 40, y: 40})
.click()
.perform();
browser.actions()
.mouseMove({x: 40, y: 40})
.click()
.perform();
browser.actions()
.mouseMove({x: 40, y: 40})
.click()
.perform();
browser.actions()
.mouseMove({x: 40, y: 40})
.click()
.perform();
`
@lbesson could you please post some example code that you have working? What version of OL are you using?
Big-picture question --> ow do I get automated clicks from Protractor/Selenium to register on the OpenLayers map?
Thank you!
-Allan
This is kinda old, but the code was something like
browser.actions().mouseMove($('.my-canvas').getWebElement(), coordinates).click().perform();
Thanks!
From: Lionel Besson [email protected] Reply-To: openlayers/ol2 [email protected] Date: Monday, April 29, 2019 at 12:05 AM To: openlayers/ol2 [email protected] Cc: allandaly [email protected], Comment [email protected] Subject: Re: [openlayers/ol2] How to test OpenLayers app with Selenium? (#1431)
This is kinda old, but the code was something like
browser.actions().mouseMove($('.my-canvas').getWebElement(), coordinates).click().perform();
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.