有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

使用按偏移量移动时,java移动目标超出边界异常

我需要单击页面中的某个点,当页面加载时,该点不在窗口中,我需要向下滚动,以便元素出现在页面上,然后找到位置并单击其旁边的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();

但最终还是犯了同样的错误

试图了解是页面滚动是问题所在,还是我正在计算偏移量不正确,没有页面滚动的引脚初始跳线是(6651067)。 卷轴后的引脚跳线为(665667)


共 (0) 个答案