问题
I am working on testing an application with open layers maps using Selenium IDE. I researched a lot about clicking on the specific point on the map but I couldn't do it. Can you please provide me some start on this.
Thanks in advance.
Regards, Rakesh
回答1:
if you don't want to change the open layers code from Selenium IDE you can run your own javaScript functions by using "runScript" as a command and write your javaScript code into the target field (don't use comments as everything is written in one line).
use the following script to fire a mousedown, mouseup and if you need a click event on the map:
var mousedownEvent = document.createEvent('MouseEvents');
mousedownEvent.initMouseEvent('mousedown', true, true, window, 0, 0, 0, yourX, yourY, false, false, false, false, 0, null);
// creates an element from where the clickEvent can be fired
// instead of using pixel you can also refer to your dom-Element by id
document.elementFromPoint(16,118).dispatchEvent(mousedownEvent);
var mouseupEvent = document.createEvent('MouseEvents');
mouseupEvent.initMouseEvent('mouseup', true, true, window, 0, 0, 0, yourX, yourY, false, false, false, false, 0, null);
// same element
document.elementFromPoint(16,118).dispatchEvent(mouseupEvent);
// in some cases a click event needs to be fired as well
来源:https://stackoverflow.com/questions/13712252/selenium-ide-testing-on-mapsopen-layers