Class: Watobo::Gui::SeleniumRC

Inherits:
BrowserControl show all
Defined in:
lib/watobo/gui/browser_preview.rb

Instance Method Summary collapse

Methods inherited from BrowserControl

#watobo_enabled?

Constructor Details

#initialize(browser_type = :firefox, prefs = {}) ⇒ SeleniumRC

Returns a new instance of SeleniumRC.



130
131
132
133
134
135
136
137
138
139
140
# File 'lib/watobo/gui/browser_preview.rb', line 130

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

Returns:

  • (Boolean)


158
159
160
# File 'lib/watobo/gui/browser_preview.rb', line 158

def busy?()
  false
end

#closeObject



178
179
180
181
# File 'lib/watobo/gui/browser_preview.rb', line 178

def close()
  @rc.quit

end

#connectObject



162
163
164
# File 'lib/watobo/gui/browser_preview.rb', line 162

def connect()
  createBrowser()
end

#createBrowser(browser_type = :firefox, proxy = nil) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/watobo/gui/browser_preview.rb', line 142

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

#getDocObject



174
175
176
# File 'lib/watobo/gui/browser_preview.rb', line 174

def getDoc()
  @rc.page_source
end


166
167
168
# File 'lib/watobo/gui/browser_preview.rb', line 166

def navigate(url)
  @rc.navigate.to(url)
end

#ready?Boolean

Returns:

  • (Boolean)


183
184
185
186
187
188
189
190
191
192
193
# File 'lib/watobo/gui/browser_preview.rb', line 183

def ready?()

  begin
    return false if @rc.nil?

  rescue => bang
    puts bang
    return false
  end
  return true
end

#visible=(status) ⇒ Object



170
171
172
# File 'lib/watobo/gui/browser_preview.rb', line 170

def visible=(status)

end