2

Selenium を使い始めたとき、非表示の要素に対してアクション (ホバー、クリックなど) を実行するのが難しいことがわかりました。これは、他の要素にホバーしたときにのみ表示されます。これが他の人に役立つことを願っています。次の方法のいずれかを使用できます..

たとえばupvote、このページのコメントでは、コンテキスト (つまりコメント) にカーソルを合わせて上向きの矢印を表示する必要があります。次に、それをクリックする必要があります。しかし、javascriptExcecuteryou を使用すると、これを 1 ステップで実行できます。

4

1 に答える 1

1
//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

Action クラスの詳細については、こちらを参照してください。

于 2013-10-11T10:10:52.273 に答える