![](/img/trans.png)
[英]Click on hidden elements with Selenium java WebDriver, without using the javascript executor?
[英]Hover and click on hidden elements with Selenium WebDriver
當我開始使用Selenium時,我發現很難對隱藏的元素執行操作(懸停,單擊..etc等),僅當將鼠標懸停在其他元素上時,該操作才可見。 因此,我希望這對其他人有幫助,您可以使用以下任何一種方法。
例如,要upvote
在此頁評論,我需要上下文(即注釋),使向上的箭頭可見盤旋,然后我需要點擊它。 但是,使用javascriptExcecuter
可以一步執行。
//this can be used even if the element is not visible
//if you want to hover over the element, replace click() with hover()
((JavascriptExecutor)driver).executeScript("$('element_selector').click();");
OR
you can use Actions class rather than using the Keyboard or Mouse directly.
It implements the builder pattern: Builds a CompositeAction containing all actions specified by method calls
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.