我有一個簡單的CSS-based dropdown menu,我嘗試點擊Java Selenium(WebDriver)測試中的一個菜單項。使用WebDriver在基於CSS的菜單中選擇一個選項
兩個菜單(<ul>
元件)和項目(<a>
)具有標識和創建相應WebElement
對象工作正常。我想點擊的項目之一,類似的代碼:
hoverOver(transfersMenu);
transferLink.click();
在hoverOver()
,我試過all three answers from this question,但他們沒有工作。我不斷收到:
org.openqa.selenium.ElementNotVisibleException:
Element is not currently visible and so may not be interacted with
Command duration or timeout: 2.06 seconds
(我已經打過電話transferLink.click()
也hoverOver()
之前,希望對隱含等待將使它的工作,但沒了。)
任何想法如何使懸停工作,以便鏈接可以點擊?
Selenium版本2.21.0。我正在使用Firefox 13.0在Linux(Ubuntu)上運行測試。一位同事剛剛在Windows上嘗試過(使用Firefox 12.0),但他也沒有爲他工作。
更新:按照Slanec在評論提示,以及these instructions,我在FirefoxProfile
嘗試setEnableNativeEvents(true)
。起初,這個失敗:
org.openqa.selenium.InvalidElementStateException:
Cannot perform native interaction: Could not load native events component.
......但之後,我升級到2.23.1硒,我不再讓投訴人。
不過,懸停不起作用(本機事件打開或關閉)。 : -/
鏈接問題的接受解決方案應該工作= /。運行測試時你實際看到了什麼? hoverOver()是否可視化地打開列表?或者不是? –
有些用戶在關於相關事情的不同問題中也建議打開/關閉本地事件。 –
@Slanec:它不能直觀地打開菜單。 (我得到測試通過的唯一方法是手動*將鼠標懸停在菜單上,這使Selenium可以點擊菜單項。)嗯,我會研究本機事件... – Jonik