Class: JstdRunner::Browser
- Inherits:
-
Object
- Object
- JstdRunner::Browser
- Includes:
- Monitorable
- Defined in:
- lib/jstd-runner/browser.rb
Instance Method Summary collapse
- #capture(host, port) ⇒ Object
-
#initialize(type = :firefox) ⇒ Browser
constructor
A new instance of Browser.
- #restart ⇒ Object
- #running? ⇒ Boolean
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
Methods included from Monitorable
Constructor Details
#initialize(type = :firefox) ⇒ Browser
Returns a new instance of Browser.
5 6 7 8 |
# File 'lib/jstd-runner/browser.rb', line 5 def initialize(type = :firefox) @type = type @switched = @restarting = false end |
Instance Method Details
#capture(host, port) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/jstd-runner/browser.rb', line 15 def capture(host, port) @restarting = true @switched = false start unless @browser @browser.get "http://#{host}:#{port}/capture" @restarting = false end |
#restart ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/jstd-runner/browser.rb', line 23 def restart @restarting = true Log.info "restarting browser - #{@type}" stop rescue nil @switched = false start @restarting = false end |
#running? ⇒ Boolean
39 40 41 42 43 44 45 |
# File 'lib/jstd-runner/browser.rb', line 39 def running? Log.info "browser state: #{status}" true rescue => ex Log.warn "#{self}#running? caught #{ex.}" false end |
#start ⇒ Object
10 11 12 13 |
# File 'lib/jstd-runner/browser.rb', line 10 def start Log.info "starting browser - #{@type}" @browser = Selenium::WebDriver.for @type end |
#status ⇒ Object
47 48 49 |
# File 'lib/jstd-runner/browser.rb', line 47 def status status_spans.map { |e| e.text }.inspect end |
#stop ⇒ Object
32 33 34 35 36 37 |
# File 'lib/jstd-runner/browser.rb', line 32 def stop Log.info "stopping browser - #{@type}" @browser.quit if @browser rescue Errno::ECONNREFUSED # looks like we're not running end |