Class: AePageObjects::MultipleWindows::WindowList

Inherits:
Object
  • Object
show all
Defined in:
lib/ae_page_objects/multiple_windows/window_list.rb

Instance Method Summary collapse

Constructor Details

#initializeWindowList

Returns a new instance of WindowList.



7
8
9
# File 'lib/ae_page_objects/multiple_windows/window_list.rb', line 7

def initialize
  @windows = {}
end

Instance Method Details

#add(window) ⇒ Object



11
12
13
# File 'lib/ae_page_objects/multiple_windows/window_list.rb', line 11

def add(window)
  @windows[window.handle] = window
end

#close_allObject



38
39
40
# File 'lib/ae_page_objects/multiple_windows/window_list.rb', line 38

def close_all
  opened.each(&:close)
end

#current_windowObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ae_page_objects/multiple_windows/window_list.rb', line 25

def current_window
  current_handle = WindowHandleManager.current

  window_for(current_handle) if current_handle
rescue WindowNotFound
  synchronize_windows

  if current_window = @windows[@windows.keys.sort.first]
    current_window.switch_to
    current_window
  end
end

#openedObject



19
20
21
22
23
# File 'lib/ae_page_objects/multiple_windows/window_list.rb', line 19

def opened
  WindowHandleManager.all.map do |handle|
    window_for(handle)
  end
end

#remove(window) ⇒ Object



15
16
17
# File 'lib/ae_page_objects/multiple_windows/window_list.rb', line 15

def remove(window)
  @windows.delete(window.handle)
end