Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用按偏移量移动时,将目标移出边界异常_Java_Selenium_Selenium Webdriver_Automation_Ui Automation - Fatal编程技术网

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

Java 使用按偏移量移动时,将目标移出边界异常,java,selenium,selenium-webdriver,automation,ui-automation,Java,Selenium,Selenium Webdriver,Automation,Ui Automation,我需要单击页面中的某个点,当页面加载时,该点不在窗口中,我需要向下滚动,以便元素出现在页面上,然后找到位置并单击其旁边的2或3个像素。但每当我尝试它,我会得到移动目标出界异常。 下面是我正在尝试的代码 Actions动作=新动作(驱动程序); WebElement anchorPin=driver.findElement(By.xpath(anchorPinPath)); Point=anchorPin.getLocation(); System.out.println(point.getX()

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

Actions动作=新动作(驱动程序);
WebElement anchorPin=driver.findElement(By.xpath(anchorPinPath));
Point=anchorPin.getLocation();
System.out.println(point.getX());
System.out.println(point.getY());
睡眠(10000);
action.moveToElement(anchorPin.build().perform();
睡眠(10000);
point=anchorPin.getLocation();
System.out.println(“新跳线”+point.getX());
System.out.println(“新跳线”+point.getY());
action.moveByOffset(0,3).contextClick().build().perform();
我还尝试了以下内容,而不是最后一行:

action.movetoElement(anchorPin).moveByOffset(0,3).contextclick.build.perform();
但最终还是犯了同样的错误

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