问题陈述:如何使用机器人类在Selenium中基于webelement而不是getlocation的xy坐标执行mousemove?
下面的代码段通常用于根据x-y坐标移动鼠标的鼠标移动
Robot robot = new Robot();
robot.mouseMove(to_x, to_y);
但是,有没有一种方法 [在不使用getlocation的Web元素上?
Example:
webelement drag = driver.findelement(by_xpath('xpaht'))
Robot robot = new Robot();
robot.mouseMove(drag); //Is there any way to do it like this in selenium java
我不想使用动作类的movetoelement。Selenium 3.141 / JavaChromedriver 76和FF浏览器
Locatable hoverItem = (Locatable) driver.findElement(By.xpath("element xpath"));enter code here
int y = hoverItem.getCoordinates().getLocationOnScreen().getY();
((JavascriptExecutor)driver).executeScript("window.scrollBy(0,"+y+");");
希望获得帮助。