LoginSignup
24
21

More than 5 years have passed since last update.

Selenium Webdriver で ウィンドウ切り替えを追う

Posted at

Selenium Webdriver 小ネタ

_target=blank で別ウィンドウ遷移時にSelenium Webdriverで追う方法について説明します。

:warning: 使用言語:Ruby

結論

下記3行でウィンドウ切り替えできます。

switch_window.rb
      window = driver.window_handles.last   # ウィンドウ情報を取得
      driver.close                          # 遷移元のウィンドウを閉じる。特に必要なければ記述の必要なし 
      driver.switch_to.window(window)       # 遷移先のウィンドウに遷移元のウィンドウ情報を移す
24
21
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
24
21