2014-01-16 52 views
0

使用在Firefox中使用移動鼠標與webdriver鼠標..但我認爲功能正在工作,因爲菜單鏈接顏色正在改變..但子菜單不diplaying..manually,如果我觸摸菜單子菜單dispying在Firefox中使用webdriver移動鼠標

我的動作代碼是在這裏

WebElement menu = driver.findElement(By.linkText("EManagement")); 
Assert.assertEquals(true, menu.isDisplayed());    
Actions action = new Actions(driver); 
action.moveToElement(menu).click().perform();    
Thread.sleep(1000); 
driver.findElement(By.id("Management")).click(); 

但我收到錯誤,如元素當前不可見,因此可能無法與之交互(警告:服務器未提供任何堆棧跟蹤信息)

我的Firefox版本是18.0.2和Seleniu m版本是2.33 任何人都可以幫我

回答

0

我曾經遇到過這個問題,你可以使用下面的java腳本。

String javaScript = "var evObj = document.createEvent('MouseEvents');" + "evObj.initMouseEvent(\"mouseover\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);" 
     + "arguments[0].dispatchEvent(evObj);"; 
     ((JavascriptExecutor) Driver.driver).executeScript(javaScript, element);