Multiple windows - Selenium in ruby

We can handle multiple windows by using 2 properties.
  • driver.window_handle – Gets the handle of current window
  • driver.window_handles – Gets the list of all browser window handles currently opened by the driver
Syntax – Consider we have 2 browser windows open
 
windowhandles = driver.window_handles

puts “First window handle ” + windowhandles[0]

puts “Second window handle ” +  windowhandles[1]

#Switch to second window.

driver.switch_to.window windowhandles[1]

Web development and Automation testing

solutions delivered!!