From: Joel Pearson Date: 2013-01-16T06:20:22+09:00 Subject: Re: Ruby + Selenium: Reuse open browser session [HELP] Examples here in Ruby: http://seleniumready.blogspot.co.uk/2010/09/how-to-create-selenium-cookies.html Play around with IRB and see what you can do with it. Perhaps if you explain what your goal is and what your obstacles are in more detail we might be able to find the best method. My examples tend to use watir-webdriver since this is what I am familiar with. If your reason for experimenting with cookies is to match what your standard profile uses, then that can be achieved with something like this: Watir::Browser.new :firefox, :profile => 'default' As far as I know Webdriver can only use windows created by the current session, since the "attach" method only existed for browsers using a COM object (IE). If you're looking to log into a page and then execute a series of other scripts, this is what I would do: _________________________________________________ require 'watir-webdriver' class BrowserTest attr_accessor :name, :pass, @driver #Not technically required def initialize @name = 'me' @pass = 'pass' end def start @driver = Watir::Browser.new end def login @driver.goto 'some-page' @driver.text_field(:id => 'name').set @name @driver.text_field(:id => 'pass').set @pass @driver.button(:name => 'go').click end def script1 puts @driver.url end def script2 puts @driver.title end def run start login puts 'Press enter to continue...' gets script1 script2 puts 'Press enter to quit' gets close end def close @driver.close end end BrowserTest.new.run -- Posted via http://www.ruby-forum.com/.