2013-11-26 45 views
0

我正在嘗試獲取鼠標懸停操作後出現的元素。怎麼做 ?如何使用webdriver操作做mouseover?

我想:

Actions action = new Actions(driver); 
action.moveToElement(elem); 
action.perform(); 
WebElement myDynamicElement = (new WebDriverWait(driver,10)).until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("class*='hoverEverywhereTooltip'"))); 

這個元素只是鼠標事件之後出現。

+1

您可以發佈您在運行此代碼時看到的錯誤嗎? – Akbar

+0

它的工作我錯過[]在我的cssSelector屬性:WebElement myDynamicElement =(新的WebDriverWait(驅動程序,10))直到(ExpectedConditions.presenceOfElementLocated(By.cssSelector(「[class * ='hoverEverywhereTooltip']」))); – SelenUser

回答

0

它的工作,我錯過[]在我cssSelector性能

WebElement myDynamicElement =(新WebDriverWait(驅動程序,10)),直到(ExpectedConditions.presenceOfElementLocated (By.c ssSelector( 「[類* = 'hoverEverywhereTooltip']」)));

0

試試這個。

代碼:

Actions actions = new Actions(driver); 
WebElement menuhover = driver.findElement(By.linkText("Menu")); 
actions.moveToElement(menuhover); 

WebElement subLink = driver.findElement(By.id("submenu")); 
actions.moveToElement(submenu); 
actions.click(); 
actions.perform();