angular - 如何使用量角器单击传单地图的中心
问题描述
我正在尝试单击页面第二列上的地图中心(因此它有一个偏移量)但它不起作用,似乎光标总是指向页面的中心:
我正在尝试使用宽度/高度的一半来添加位置,这是代码:
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()
, 来更改选择器,但没有任何效果
解决方案
所以我找到了一个解决方案,默认情况下,当我点击地图元素时,量角器点击中心:
await pageObject.getMap().click();
要单击特定地址,我直接在地理编码器栏上输入地址,然后单击地图以获取中心,但我没有找到解决方案 moveMove(element, { x, y })
推荐阅读
- angular - 如何合并来自参考的阵列的角火结果
- javascript - Vue js 观看 vue 漂亮的复选框值
- r - 数据/文件夹R包中的.Rdata文件中有两个R对象?
- microsoft-graph-api - 从会话(sessionStorage)中获取“adal.access.token.key|https://graph.microsoft.com”
- python - python中的卷曲请求
- android - 在 Kotlin/Java 中使用什么来进行有效的浮点集合处理?
- java - 在区块链中查找最新区块的最有效实现
- java - 为什么铸造给我这些奇怪的结果Java?
- neo4j - Popoto.js 自定义密码查询
- javascript - 尝试查找总和时连接的Javascript参数