LoginSignup
16
13

More than 5 years have passed since last update.

Selenium Webdriver(Ruby) で操作対象ウィンドウを切り替える方法

Posted at

リンク押下で新しいウィンドウが開くタイプのページのテストで使う。
日本語でぐぐって出てくる情報が古いのでメモ。

動作確認したバージョン

  • selenium-webdriver : 2.42.0
  • Chrome : 36
  • chromedriver : 2.10

やり方

sample
# 新しいウィンドウを開くボタン押下
@driver.find_element(:id, "open_new_window_button").click

# 操作対象を新しいウィンドウに切り替える
@driver.switch_to.window(@driver.window_handles.last)

参考URL

■ruby - How do you get window titles, ids, and names in selenium-webdriver? - Stack Overflow
http://stackoverflow.com/questions/9692460/how-do-you-get-window-titles-ids-and-names-in-selenium-webdriver

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