Class: Girbot::BrowserHolder
- Inherits:
-
Object
- Object
- Girbot::BrowserHolder
- Defined in:
- lib/girbot/browser_holder.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
Returns the value of attribute browser.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#which ⇒ Object
Returns the value of attribute which.
Instance Method Summary collapse
- #chrome ⇒ Object
- #chrome_proxy(proxy) ⇒ Object
- #firefox ⇒ Object
- #firefox_proxy(proxy) ⇒ Object
- #init ⇒ Object
-
#initialize(which = 'firefox', proxy = nil) ⇒ BrowserHolder
constructor
A new instance of BrowserHolder.
Constructor Details
#initialize(which = 'firefox', proxy = nil) ⇒ BrowserHolder
Returns a new instance of BrowserHolder.
5 6 7 8 |
# File 'lib/girbot/browser_holder.rb', line 5 def initialize which='firefox', proxy=nil @which = which @proxy = proxy end |
Instance Attribute Details
#browser ⇒ Object
Returns the value of attribute browser.
3 4 5 |
# File 'lib/girbot/browser_holder.rb', line 3 def browser @browser end |
#proxy ⇒ Object
Returns the value of attribute proxy.
3 4 5 |
# File 'lib/girbot/browser_holder.rb', line 3 def proxy @proxy end |
#which ⇒ Object
Returns the value of attribute which.
3 4 5 |
# File 'lib/girbot/browser_holder.rb', line 3 def which @which end |
Instance Method Details
#chrome ⇒ Object
28 29 30 |
# File 'lib/girbot/browser_holder.rb', line 28 def chrome Watir::Browser.new :chrome end |
#chrome_proxy(proxy) ⇒ Object
32 33 34 35 |
# File 'lib/girbot/browser_holder.rb', line 32 def chrome_proxy proxy switches = "--proxy-server=#{proxy}" Watir::Browser.new :chrome, :switches => switches end |
#firefox ⇒ Object
18 19 20 |
# File 'lib/girbot/browser_holder.rb', line 18 def firefox Watir::Browser.new :firefox end |
#firefox_proxy(proxy) ⇒ Object
22 23 24 25 26 |
# File 'lib/girbot/browser_holder.rb', line 22 def firefox_proxy proxy profile = Selenium::WebDriver::Firefox::Profile.new profile.proxy = Selenium::WebDriver::Proxy.new :http => proxy, :ssl => proxy Watir::Browser.new :firefox, :profile => profile end |
#init ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/girbot/browser_holder.rb', line 10 def init if @proxy.nil? @browser = send(@which) else @browser = send("#{@which}_proxy", @proxy) end end |