0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Selenium DOM要素をホバー&クリックする方法

Last updated at Posted at 2021-01-20

Seleniumを使用してDOM要素をホバーしてからクリックする方法について明記します。

SeleniumはWebサイトやWebページの閲覧を自動化することができます。
今回は、抽出したDOM要素をホバーしてからクリックする方法について明記します。
要素をホバーすることでプログラム上、マウスカーソルがDOM要素に重なっている状態を擬似的に表現します。

Java
import org.openqa.selenium.interactions.Actions;

public static void autoHoverClick(WebDriver driver, WebElement element){
	Actions act = new Actions(driver);
	act.moveToElement(element).perform(); // 指定したDOM要素をホバーする(hover)
	element.click(); // DOM要素をクリック
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?