Class: AePageObjects::Window

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

Defined Under Namespace

Classes: HandleManager, Registry

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry, handle) ⇒ Window

Returns a new instance of Window.



101
102
103
104
105
106
107
# File 'lib/ae_page_objects/window.rb', line 101

def initialize(registry, handle)
  @registry         = registry
  @handle           = handle
  @current_document = nil

  @registry.add(self)
end

Instance Attribute Details

#current_documentObject

Returns the value of attribute current_document.



99
100
101
# File 'lib/ae_page_objects/window.rb', line 99

def current_document
  @current_document
end

#handleObject (readonly)

Returns the value of attribute handle.



99
100
101
# File 'lib/ae_page_objects/window.rb', line 99

def handle
  @handle
end

Class Method Details

.allObject



78
79
80
81
82
# File 'lib/ae_page_objects/window.rb', line 78

def all
  HandleManager.all.map do |handle|
    find(handle)
  end
end

.close_allObject



74
75
76
# File 'lib/ae_page_objects/window.rb', line 74

def close_all
  all.each(&:close)
end

.create(handle) ⇒ Object



94
95
96
# File 'lib/ae_page_objects/window.rb', line 94

def create(handle)
  new(registry, handle)
end

.currentObject



88
89
90
91
92
# File 'lib/ae_page_objects/window.rb', line 88

def current
  current_handle = HandleManager.current

  find(current_handle) if current_handle
end

.find(handle) ⇒ Object



84
85
86
# File 'lib/ae_page_objects/window.rb', line 84

def find(handle)
  registry[handle] || create(handle)
end

.registryObject



70
71
72
# File 'lib/ae_page_objects/window.rb', line 70

def registry
  @registry ||= Registry.new
end

Instance Method Details

#closeObject



119
120
121
122
123
124
# File 'lib/ae_page_objects/window.rb', line 119

def close
  if HandleManager.close(@handle)
    self.current_document = nil
    @registry.remove(self)
  end
end

#switch_toObject



114
115
116
117
# File 'lib/ae_page_objects/window.rb', line 114

def switch_to
  HandleManager.switch_to(handle)
  current_document
end