16
13

More than 5 years have passed since last update.

【メモ】Selenium で新しく開いたウインドウにスイッチする

Posted at

Selenium で新しく開いたウインドウにスイッチする方法。

Scala
    val currentWindowHandle = driver.getWindowHandle()
    val windowHandles = driver.getWindowHandles()
    windowHandles.remove(currentWindowHandle)
    driver.switchTo().window(windowHandles.iterator().next())

ようするに、現在の Window Handle と、ドライバーが制御している全ての Window Handle を取得する。
現在の Window Handle と違うものが新しいウインドウだという理屈。

16
13
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
16
13