require 'selenium-webdriver'
driver = Selenium::WebDriver.for :firefox
driver.get "https://www.google.co.in/"
address = driver.find_element(:link_text, "Gmail").attribute('href')
driver.execute_script( "window.open()" )
p driver.window_handles.first #=> 
"{f17eac79-daf9-4a6c-a1ff-1b524fef9faf}"
driver.switch_to.window( driver.window_handles.last )
driver.get address
driver.execute_script "window.close()"
# driver.execute_script "window.close()"
p driver.window_handles.first #=> 
"{f17eac79-daf9-4a6c-a1ff-1b524fef9faf}"
driver.switch_to.window( driver.window_handles.first )
p driver.title #=> "Google"
driver.close #why does here this browser not getting closed?

-- 
Posted via http://www.ruby-forum.com/.