【发布时间】:2020-03-09 06:49:46
【问题描述】:
我正在尝试单击页面第二列上的地图中心(因此它有一个偏移量)但它不起作用,似乎光标总是指向中心页面:
我正在尝试使用宽度/高度的一半来添加位置,这是代码:
it('should select center point', async () => {
const map = pageObject.getMap(); // $('.map-container')
const size = await map.getSize();
const location = await map.getLocation();
const halfWidth = parseInt(await map.getAttribute('clientWidth'), 10) / 2;
const halfHeight = parseInt(await map.getAttribute('clientHeight'), 10) / 2;
const x = location.x + halfWidth;
const y = location.y + halfHeight;
await browser
.actions()
.mouseMove(map, { x, y })
.click()
.perform();
console.log('size', size); { height: 482, width: 840 }
console.log('location', location); { x: 523, y:145 }
console.log('halfWidth', halfWidth); // 420
console.log('halfHeight', halfHeight); // 241
console.log('x', x); // 943
console.log('y', y); // 386
debugger;
});
窗口大小是1380*668 所以943 和386 似乎是正确的,我不知道为什么它不起作用。
我也尝试过不处理偏移,但它不起作用:
await browser
.actions()
.mouseMove(map, { x: halfWidth, y: halfHeight })
.click()
.perform();
我尝试使用map.getWebElement() 来更改选择器,但没有任何效果
【问题讨论】:
标签: angular typescript selenium protractor leaflet