Selenium IDE testing on maps(Open Layers)

半世苍凉 提交于 2019-12-13 01:46:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!