移动目标越界异常,当使用移动偏移

问题描述

我需要点击页面中的某个点,当页面加载时该点不存在于窗口中,我需要向下滚动以便元素出现在页面上,然后找到该位置并点击旁边的 2 或 3 个像素它。但是每当我尝试它时,我都会将目标移动到越界异常。 下面是我正在尝试的代码

Actions action = new Actions(driver);
WebElement anchorPin = driver.findElement(By.xpath(anchorPinPath));
Point point = anchorPin.getLocation();
System.out.println(point.getX());
System.out.println(point.getY());
Thread.sleep(10000);
action.movetoElement(anchorPin).build().perform();
Thread.sleep(10000);
point = anchorPin.getLocation();
System.out.println("new cords " + point.getX());
System.out.println("new cords " + point.getY());
action.moveByOffset(0,3).contextClick().build().perform();

我也尝试了以下而不是最后一行:

action.movetoElement(anchorPin).moveByOffset(0,3).contextclick.build.perform();

但还是以同样的错误告终。

试图了解页面滚动是否是问题,或者我正在计算没有页面滚动的引脚的偏移不正确的初始线是 (665,1067)。 卷轴后大头针的绳索是(665,667)。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)