Module: Watirloo::Desktop

Defined in:
lib/watirloo/desktop.rb

Overview

The browser desktop manager checks to see what browsers already exist on the dekstop. compares what is on the desktop to what was there last time

Class Method Summary collapse

Class Method Details

.additions(known_hwnds) ⇒ Object

returns handles for browsers that appeared on Desktop since the last scan for browsers



25
26
27
# File 'lib/watirloo/desktop.rb', line 25

def additions(known_hwnds)
  hwnds.select {|h| !known_hwnds.include?(h)}
end

.browsersObject

returns browser windows found on the desktop



11
12
13
14
15
# File 'lib/watirloo/desktop.rb', line 11

def browsers
  brs =[]
  Watir::IE.each {|ie| brs << ie }
  brs
end

.clearObject

Closes all the browsers on the desktop. Creats a known clear slate where no browsers exist

Raises:

  • (Exception)


36
37
38
39
40
# File 'lib/watirloo/desktop.rb', line 36

def clear
  browsers.each {|ie| ie.close; sleep 3}
  sleep 3
  raise Exception, "Failed to clear all the browsers from the desktop" unless browsers.empty?
end

.deletions(known_hwnds) ⇒ Object

returns handles for browsers no longer found on the Desktop since the last scan for browsers



30
31
32
# File 'lib/watirloo/desktop.rb', line 30

def deletions(known_hwnds)
  known_hwnds.select {|h| !hwnds.include?(h)}
end

.hwndsObject

return handles of Browsers found on desktop



18
19
20
21
22
# File 'lib/watirloo/desktop.rb', line 18

def hwnds
  hs =[]
  browsers.each {|ie| hs << ie.hwnd}
  hs
end