Hmm, here's the factory we use to make browsers sessions:
```ruby
require 'watir-webdriver'
require 'webdriver-user-agent'
require './config/application'
include Selenium
class WatirBrowserFactory
def self.create(browser_type=nil)
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 120
browser_type = ENV['CAPYBARA'] || :firefox
puts browser_type
case browser_type.to_sym
when :chrome
return Watir::Browser.new :chrome, http_client: client
when :safari
return Watir::Browser.new :safari, http_client: client
when :ie9
Watir::Rails.host = local_ip
driver = Selenium::WebDriver.for :remote, :url =>
'http://win7-ie9:4444/wd/hub', :desired_capabilities => :ie, http_client: client
driver.manage.timeouts.implicit_wait = 10
driver.manage.window.maximize
return Watir::Browser.new driver
when :ie10
Watir::Rails.host = local_ip
driver = Selenium::WebDriver.for :remote, :url =>
'http://win7-ie10:4444/wd/hub', :desired_capabilities => :ie, http_client:
client
driver.manage.timeouts.implicit_wait = 10
driver.manage.window.maximize
return Watir::Browser.new driver
when :mobile_firefox
driver = Webdriver::UserAgent.driver(:browser => :firefox, :agent =>
:iphone, :orientation => :portrait)
return Watir::Browser.new driver
when :mobile_simulator
driver = Selenium::WebDriver.for :remote, :url =>
"http://localhost:5555/wd/hub", :desired_capabilities => :iphone
driver.manage.timeouts.implicit_wait = 30
return Watir::Browser.new driver
else
profile = Selenium::WebDriver::Firefox::Profile.new
profile.native_events = false
browser = Watir::Browser.new :firefox, http_client: client, profile:
profile
browser.driver.manage.window.maximize
#width = browser.execute_script("return screen.width;")
#height = browser.execute_script("return screen.height;")
#browser.driver.manage.window.move_to(0,0)
#browser.driver.manage.window.resize_to(width,height)
return browser
end
end
def self.local_ip
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true #
turn off reverse DNS resolution temporarily
UDPSocket.open do |s|
s.connect '64.233.187.99', 1
s.addr.last
end
ensure
Socket.do_not_reverse_lookup = orig
end
end
```
---
Reply to this email directly or view it on GitHub:
https://github.com/watir/watir/commit/4e2fa0a279d09b3ebc2b22b23302d1be8aa8add3#commitcomment-4280604_______________________________________________
Wtr-development mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-development