6
我试图自动拖动&使用量角器/ Selenium检查基于瓦片(传单库)的地图是否正常工作,但无法自动化拖动&放下操作(平移地图)。使用量角器拖放(地图平移)
我已加载了页面的地图,像这样的: http://tombatossals.github.io/angular-leaflet-directive/examples/center-example.html
这量角器测试不平移地图时,dragAndDrop行动在选定的图像似乎并不工作。
describe('Panning map', function() {
var ptor, driver;
beforeEach(function() {
ptor = protractor.getInstance();
browser.get('center-example.html');
driver = ptor.driver;
}, 30000);
it('should update the center value if the map is dragged', function() {
var el = element(by.xpath('.//img[contains(@class, "leaflet-tile-loaded")][1]'));
browser.actions().dragAndDrop(el.find(), { x: 40, y: 40 }).perform();
ptor.sleep(2000);
expect(element(by.model("london.lat")).getAttribute("value")).toBe('51.505');
expect(element(by.model("london.lng")).getAttribute("value")).toBe('-1.09');
});
});
这可能是dragAndDrop操作不适用于这样的例子的原因?
有趣。您是否检出了Leaflet的[事件文档](http://leafletjs.com/reference.html#map-dragging)? – geraldarthur
Yess。我已经在Leaflet源代码中查找它以查找拖动元素,实际上它是img:https://github.com/Leaflet/Leaflet/blob/master/src/dom/Draggable.js#L87,但是我无法使用量角器自动拖动动作。 – tombatossals
我试着用你的示例页面,但也失败了。你找到解决方案吗? –