ae_page_objects 0.4.0 → 0.4.1.dt3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/ae_page_objects.rb
CHANGED
@@ -23,6 +23,7 @@ module AePageObjects
|
|
23
23
|
autoload :Visitable, 'ae_page_objects/concerns/visitable'
|
24
24
|
end
|
25
25
|
|
26
|
+
autoload :Window, 'ae_page_objects/window'
|
26
27
|
autoload :Node, 'ae_page_objects/node'
|
27
28
|
autoload :Document, 'ae_page_objects/document'
|
28
29
|
autoload :Element, 'ae_page_objects/element'
|
@@ -1,11 +1,16 @@
|
|
1
1
|
module AePageObjects
|
2
2
|
class Document < Node
|
3
3
|
include Concerns::Visitable
|
4
|
+
|
5
|
+
attr_reader :window
|
4
6
|
|
5
7
|
def initialize
|
6
8
|
super(Capybara.current_session)
|
7
|
-
end
|
8
9
|
|
10
|
+
@window = Window.current
|
11
|
+
@window.current_document = self
|
12
|
+
end
|
13
|
+
|
9
14
|
def document
|
10
15
|
self
|
11
16
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module AePageObjects
|
2
|
+
class Window
|
3
|
+
class << self
|
4
|
+
def all
|
5
|
+
@all ||= {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def current
|
9
|
+
current_handle = Capybara.current_session.driver.browser.window_handle
|
10
|
+
|
11
|
+
window = all.keys.find do |window|
|
12
|
+
window.handle == current_handle
|
13
|
+
end
|
14
|
+
|
15
|
+
unless window
|
16
|
+
window = new(current_handle)
|
17
|
+
all[window] = window
|
18
|
+
end
|
19
|
+
|
20
|
+
window
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
attr_reader :current_document, :handle
|
25
|
+
|
26
|
+
def initialize(handle)
|
27
|
+
@handle = handle
|
28
|
+
@current_document = nil
|
29
|
+
|
30
|
+
self.class.all[self] = self
|
31
|
+
end
|
32
|
+
|
33
|
+
def current_document=(document)
|
34
|
+
@current_document.send(:stale!) if @current_document
|
35
|
+
@current_document = document
|
36
|
+
end
|
37
|
+
|
38
|
+
def switch_to
|
39
|
+
Capybara.current_session.driver.browser.switch_to.window(handle)
|
40
|
+
current_document
|
41
|
+
end
|
42
|
+
|
43
|
+
def close
|
44
|
+
self.current_document = nil
|
45
|
+
|
46
|
+
Capybara.current_session.execute_script("window.close();")
|
47
|
+
|
48
|
+
self.class.all.delete(self)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ae_page_objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 4196270005
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
|
9
|
+
- 1
|
10
|
+
- dt
|
11
|
+
- 3
|
12
|
+
version: 0.4.1.dt3
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Donnie Tognazzini
|
@@ -113,6 +115,7 @@ files:
|
|
113
115
|
- lib/ae_page_objects/util/internal_helpers.rb
|
114
116
|
- lib/ae_page_objects/util/singleton.rb
|
115
117
|
- lib/ae_page_objects/version.rb
|
118
|
+
- lib/ae_page_objects/window.rb
|
116
119
|
homepage: http://github.com/appfolio/ae_page_objects
|
117
120
|
licenses:
|
118
121
|
- MIT
|