class AePageObjects::MultipleWindows::WindowList
Public Class Methods
new()
click to toggle source
# File lib/ae_page_objects/multiple_windows/window_list.rb, line 7 def initialize @windows = {} end
Public Instance Methods
add(window)
click to toggle source
# File lib/ae_page_objects/multiple_windows/window_list.rb, line 11 def add(window) @windows[window.handle] = window end
close_all()
click to toggle source
# File lib/ae_page_objects/multiple_windows/window_list.rb, line 38 def close_all opened.each(&:close) end
current_window()
click to toggle source
# 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
opened()
click to toggle source
# 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)
click to toggle source
# File lib/ae_page_objects/multiple_windows/window_list.rb, line 15 def remove(window) @windows.delete(window.handle) end
Private Instance Methods
synchronize_windows()
click to toggle source
# File lib/ae_page_objects/multiple_windows/window_list.rb, line 44 def synchronize_windows existence_unverified_window_handles = @windows.keys WindowHandleManager.all.map do |handle| # If it exists in the browser, it's been verified existence_unverified_window_handles.delete(handle) end # Remove the windows that no longer exist. existence_unverified_window_handles.each do |non_existing_window_handle| @windows.delete(non_existing_window_handle) end end
window_for(handle)
click to toggle source
# File lib/ae_page_objects/multiple_windows/window_list.rb, line 58 def window_for(handle) @windows[handle] ||= Window.new(self, handle) end