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 と違うものが新しいウインドウだという理屈。