Class: AutoPilot::Browser
- Inherits:
-
Object
- Object
- AutoPilot::Browser
- Defined in:
- lib/auto_pilot/browser.rb
Overview
Represents a browser instance.
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#port ⇒ Object
Returns the value of attribute port.
-
#suite ⇒ Object
Returns the value of attribute suite.
Instance Method Summary collapse
-
#initialize(name, suite, port = 3001) ⇒ Browser
constructor
A new instance of Browser.
-
#start ⇒ Object
:nodoc:.
-
#stop ⇒ Object
:nodoc:.
Constructor Details
#initialize(name, suite, port = 3001) ⇒ Browser
Returns a new instance of Browser.
6 7 8 9 10 |
# File 'lib/auto_pilot/browser.rb', line 6 def initialize(name, suite, port=3001) @name = name @suite = suite @port = port end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/auto_pilot/browser.rb', line 5 def name @name end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/auto_pilot/browser.rb', line 5 def port @port end |
#suite ⇒ Object
Returns the value of attribute suite.
5 6 7 |
# File 'lib/auto_pilot/browser.rb', line 5 def suite @suite end |
Instance Method Details
#start ⇒ Object
:nodoc:
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/auto_pilot/browser.rb', line 12 def start #:nodoc: url_suffix = "&auto=true&resultsUrl=http://localhost:#{@port}/postResults" windows_url_suffix = "^&auto=true^&resultsUrl=http://localhost:#{@port}/postResults" if(HOST_OS == MACOS) #assuming Firefox for now--Safari is more problematic `open "#{suite}#{url_suffix}"` if(@name == SAFARI) @browser_process = Process.fork {`/Applications/FireFox.app/Contents/MacOS/firefox-bin "#{@suite}#{url_suffix}"`} if(@name == FIREFOX) Process.detach(@browser_process) end # Linux: NOT IMPLEMENTED. if(HOST_OS == LINUX) if(@name == FIREFOX) end end # Windows if(HOST_OS == WINDOWS) `start #{suite}#{windows_url_suffix}` if(@name == IE) `start firefox.exe #{@suite}#{windows_url_suffix}` if(@name == FIREFOX) end end |
#stop ⇒ Object
:nodoc:
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/auto_pilot/browser.rb', line 36 def stop #:nodoc: if(HOST_OS == MACOS) #assuming Firefox for now # puts 'SIGKILL', @browser_process # Process.kill('SIGKILL', @browser_process) if(@name == FIREFOX) line = `ps -A | grep "FireFox.app"` puts line process = line.split puts "Killing #{@name}, process # #{process[0]}" `kill -9 #{process[0]}` elsif(@name == SAFARI) line = `ps -A | grep "Safari.app"` process = line.split puts "Killing #{@name}, process # #{process[0]}" `kill #{process[0]}` end end if(HOST_OS == WINDOWS) `TASKKILL /F /IM iexplore.exe /T` if(@name == IE) `TASKKILL /F /IM firefox.exe /T` if(@name == FIREFOX) end end |