Class: Watobo::Gui::SeleniumRC
- Inherits:
-
BrowserControl
- Object
- BrowserControl
- Watobo::Gui::SeleniumRC
- Defined in:
- lib/watobo/gui/browser_preview.rb
Instance Method Summary collapse
- #busy? ⇒ Boolean
- #close ⇒ Object
- #connect ⇒ Object
- #createBrowser(browser_type = :firefox, proxy = nil) ⇒ Object
- #getDoc ⇒ Object
-
#initialize(browser_type = :firefox, prefs = {}) ⇒ SeleniumRC
constructor
A new instance of SeleniumRC.
- #navigate(url) ⇒ Object
- #ready? ⇒ Boolean
- #visible=(status) ⇒ Object
Methods inherited from BrowserControl
Constructor Details
#initialize(browser_type = :firefox, prefs = {}) ⇒ SeleniumRC
Returns a new instance of SeleniumRC.
118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/watobo/gui/browser_preview.rb', line 118 def initialize(browser_type = :firefox, prefs = {}) proxy = "127.0.0.1:8081" @rc = nil proxy = prefs[:proxy] if prefs.has_key? :proxy begin # require 'selenium-webdriver' @rc = createBrowser(browser_type, proxy) rescue => bang puts "[#{self}] Could not create selenium driver" end end |
Instance Method Details
#busy? ⇒ Boolean
146 147 148 |
# File 'lib/watobo/gui/browser_preview.rb', line 146 def busy?() false end |
#close ⇒ Object
166 167 168 169 |
# File 'lib/watobo/gui/browser_preview.rb', line 166 def close() @rc.quit end |
#connect ⇒ Object
150 151 152 |
# File 'lib/watobo/gui/browser_preview.rb', line 150 def connect() createBrowser() end |
#createBrowser(browser_type = :firefox, proxy = nil) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/watobo/gui/browser_preview.rb', line 130 def createBrowser( browser_type = :firefox, proxy = nil ) profile = nil unless proxy.nil? puts "[Preview] create preview with proxy #{proxy}" if $DEBUG profile = Selenium::WebDriver::Firefox::Profile.new driver_proxy = Selenium::WebDriver::Proxy.new(:http => proxy) profile.proxy = driver_proxy @rc = Selenium::WebDriver.for :firefox, :profile => profile else @rc = Selenium::WebDriver.for browser_type end end |
#getDoc ⇒ Object
162 163 164 |
# File 'lib/watobo/gui/browser_preview.rb', line 162 def getDoc() @rc.page_source end |
#navigate(url) ⇒ Object
154 155 156 |
# File 'lib/watobo/gui/browser_preview.rb', line 154 def navigate(url) @rc.navigate.to(url) end |
#ready? ⇒ Boolean
171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/watobo/gui/browser_preview.rb', line 171 def ready?() begin return false if @rc.nil? rescue => bang puts bang return false end return true end |
#visible=(status) ⇒ Object
158 159 160 |
# File 'lib/watobo/gui/browser_preview.rb', line 158 def visible=(status) end |