Class: Vapir::IE::Process
- Inherits:
-
Object
- Object
- Vapir::IE::Process
- Defined in:
- lib/vapir-ie/ie-process.rb
Instance Attribute Summary collapse
-
#process_id ⇒ Object
readonly
Returns the value of attribute process_id.
Class Method Summary collapse
-
.start ⇒ Object
start a new IE process and return a new Vapir::IE::Process object representing it.
Instance Method Summary collapse
-
#browser_object(options = {}) ⇒ Object
returns the browser object corresponding to the process id.
-
#initialize(process_id) ⇒ Process
constructor
takes a process id.
Constructor Details
#initialize(process_id) ⇒ Process
takes a process id
33 34 35 |
# File 'lib/vapir-ie/ie-process.rb', line 33 def initialize process_id @process_id = process_id end |
Instance Attribute Details
#process_id ⇒ Object (readonly)
Returns the value of attribute process_id.
36 37 38 |
# File 'lib/vapir-ie/ie-process.rb', line 36 def process_id @process_id end |
Class Method Details
.start ⇒ Object
start a new IE process and return a new Vapir::IE::Process object representing it.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vapir-ie/ie-process.rb', line 21 def self.start require 'win32/process' program_files = ENV['ProgramFiles'] || "c:\\Program Files" startup_command = "#{program_files}\\Internet Explorer\\iexplore.exe" startup_command << " -nomerge" if ::Vapir::IE.version_parts.first==8 # maybe raise an error here if it's > 8, as not-yet-supported? who knows what incompatibilities the future will hold process_info = ::Process.create('app_name' => "#{startup_command} about:blank") process_id = process_info.process_id new process_id end |
Instance Method Details
#browser_object(options = {}) ⇒ Object
returns the browser object corresponding to the process id
39 40 41 42 43 44 45 46 47 |
# File 'lib/vapir-ie/ie-process.rb', line 39 def browser_object(={}) =(, :timeout => 32) Vapir.require_winwindow ::Waiter.try_for([:timeout], :exception => RuntimeError.new("Could not find a browser for process #{self.inspect}")) do Vapir::IE.browser_objects.detect do |browser_object| @process_id == WinWindow.new(Vapir::IE.fix_win32ole_hwnd(browser_object.hwnd)).process_id end end end |