2017-02-26 63 views
0

硒的webdriver:鼠標光標懸停不工作的火狐版本50硒的webdriver:鼠標光標懸停不工作

import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.interactions.Actions; 
public class Ajax_Mouse_Interactions { 
public static void main(String[] args) throws InterruptedException { 

路徑爲Firefox司機

System.setProperty("webdriver.gecko.driver", 
"C://Users//user2//Downloads//geckodriver-v0.11.1-win64//geckodriver.exe"); 

WebDriver driver = new FirefoxDriver(); 

driver.get("http://www.amazon.in/");   

Thread.sleep(20000);       

操作類用於鼠標處理

Actions action = new Actions(driver); 

WebElement element=driver.findElement(By.linkText("nav-link-yourAccount")); 

action.moveToElement(element).build().perform(); 
} 
} 

獲得以下異常

Upsupported命令異常

回答

0

現在我想這一點。 此代碼適用於我。

import java.awt.Robot; 
... 
Point point = webDriver.findElement(By.xpath("//a[@title='Emitir Guias']")).getLocation(); 
System.out.println(point.toString()); 
Robot robot = new Robot(); 
robot.mouseMove(point.x+10,point.y+110); //This 10 and 110 just to adjust coordenate in my case 

Thread.sleep(3000); //Pause for you see the mouse move 

來源https://stackoverflow.com/posts/12978079/revisions