page-object 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.coveralls.yml +1 -1
- data/.gitignore +8 -8
- data/.rspec +2 -2
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/.travis.yml +17 -17
- data/ChangeLog +923 -888
- data/Gemfile +13 -13
- data/Guardfile +20 -20
- data/LICENSE +20 -20
- data/README.md +114 -114
- data/Rakefile +29 -29
- data/cucumber.yml +8 -8
- data/lib/page-object.rb +431 -420
- data/lib/page-object/accessors.rb +1201 -1175
- data/lib/page-object/element_locators.rb +21 -21
- data/lib/page-object/elements.rb +62 -61
- data/lib/page-object/elements/area.rb +9 -9
- data/lib/page-object/elements/audio.rb +9 -9
- data/lib/page-object/elements/bold.rb +9 -9
- data/lib/page-object/elements/button.rb +12 -12
- data/lib/page-object/elements/canvas.rb +10 -10
- data/lib/page-object/elements/check_box.rb +9 -9
- data/lib/page-object/elements/date_field.rb +10 -0
- data/lib/page-object/elements/div.rb +9 -9
- data/lib/page-object/elements/element.rb +212 -159
- data/lib/page-object/elements/file_field.rb +9 -9
- data/lib/page-object/elements/form.rb +9 -9
- data/lib/page-object/elements/heading.rb +14 -14
- data/lib/page-object/elements/hidden_field.rb +9 -9
- data/lib/page-object/elements/image.rb +10 -10
- data/lib/page-object/elements/italic.rb +9 -9
- data/lib/page-object/elements/label.rb +9 -9
- data/lib/page-object/elements/link.rb +9 -9
- data/lib/page-object/elements/list_item.rb +9 -9
- data/lib/page-object/elements/media.rb +11 -11
- data/lib/page-object/elements/option.rb +9 -9
- data/lib/page-object/elements/ordered_list.rb +43 -45
- data/lib/page-object/elements/paragraph.rb +9 -9
- data/lib/page-object/elements/radio_button.rb +9 -9
- data/lib/page-object/elements/select_list.rb +42 -42
- data/lib/page-object/elements/span.rb +9 -9
- data/lib/page-object/elements/table.rb +85 -68
- data/lib/page-object/elements/table_cell.rb +10 -10
- data/lib/page-object/elements/table_row.rb +52 -52
- data/lib/page-object/elements/text_area.rb +9 -9
- data/lib/page-object/elements/text_field.rb +10 -10
- data/lib/page-object/elements/unordered_list.rb +42 -44
- data/lib/page-object/elements/video.rb +9 -9
- data/lib/page-object/indexed_properties.rb +41 -41
- data/lib/page-object/javascript/angularjs.rb +14 -14
- data/lib/page-object/javascript/jquery.rb +14 -14
- data/lib/page-object/javascript/prototype.rb +14 -14
- data/lib/page-object/javascript/yui.rb +18 -18
- data/lib/page-object/javascript_framework_facade.rb +80 -80
- data/lib/page-object/locator_generator.rb +183 -182
- data/lib/page-object/nested_elements.rb +17 -17
- data/lib/page-object/page_factory.rb +108 -108
- data/lib/page-object/page_populator.rb +105 -95
- data/lib/page-object/platforms/watir.rb +50 -50
- data/lib/page-object/platforms/watir/page_object.rb +1155 -1124
- data/lib/page-object/section_collection.rb +16 -16
- data/lib/page-object/version.rb +4 -4
- data/lib/page-object/widgets.rb +98 -98
- data/page-object.gemspec +32 -32
- metadata +12 -12
@@ -1,21 +1,21 @@
|
|
1
|
-
require 'page-object/locator_generator'
|
2
|
-
|
3
|
-
module PageObject
|
4
|
-
module ElementLocators
|
5
|
-
|
6
|
-
def self.included(cls)
|
7
|
-
::PageObject::LocatorGenerator.generate_locators(cls)
|
8
|
-
end
|
9
|
-
|
10
|
-
def element(tag, identifier={:index => 0})
|
11
|
-
platform.element_for(tag, identifier.clone)
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def locator(identifier)
|
17
|
-
identifier[0] ? identifier[0] : {:index => 0}
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
1
|
+
require 'page-object/locator_generator'
|
2
|
+
|
3
|
+
module PageObject
|
4
|
+
module ElementLocators
|
5
|
+
|
6
|
+
def self.included(cls)
|
7
|
+
::PageObject::LocatorGenerator.generate_locators(cls)
|
8
|
+
end
|
9
|
+
|
10
|
+
def element(tag, identifier={:index => 0})
|
11
|
+
platform.element_for(tag, identifier.clone)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def locator(identifier)
|
17
|
+
identifier[0] ? identifier[0] : {:index => 0}
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/page-object/elements.rb
CHANGED
@@ -1,61 +1,62 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class << self
|
4
|
-
|
5
|
-
#
|
6
|
-
# method to return the collection of tag_name to class mappings
|
7
|
-
#
|
8
|
-
def tag_to_class
|
9
|
-
@tag_to_class ||= {}
|
10
|
-
end
|
11
|
-
|
12
|
-
def type_to_class
|
13
|
-
@type_to_class ||= {}
|
14
|
-
end
|
15
|
-
|
16
|
-
#
|
17
|
-
# method to return the element for a tag_name
|
18
|
-
#
|
19
|
-
def element_class_for(tag_name, type=nil)
|
20
|
-
return type_to_class[type.to_sym] if type
|
21
|
-
tag_to_class[tag_name.to_sym] || ::PageObject::Elements::Element
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
require 'page-object/elements/element'
|
30
|
-
require 'page-object/elements/link'
|
31
|
-
require 'page-object/elements/text_field'
|
32
|
-
require 'page-object/elements/
|
33
|
-
require 'page-object/elements/
|
34
|
-
require 'page-object/elements/
|
35
|
-
require 'page-object/elements/
|
36
|
-
require 'page-object/elements/
|
37
|
-
require 'page-object/elements/
|
38
|
-
require 'page-object/elements/
|
39
|
-
require 'page-object/elements/
|
40
|
-
require 'page-object/elements/
|
41
|
-
require 'page-object/elements/
|
42
|
-
require 'page-object/elements/
|
43
|
-
require 'page-object/elements/
|
44
|
-
require 'page-object/elements/
|
45
|
-
require 'page-object/elements/
|
46
|
-
require 'page-object/elements/
|
47
|
-
require 'page-object/elements/
|
48
|
-
require 'page-object/elements/
|
49
|
-
require 'page-object/elements/
|
50
|
-
require 'page-object/elements/
|
51
|
-
require 'page-object/elements/
|
52
|
-
require 'page-object/elements/
|
53
|
-
require 'page-object/elements/
|
54
|
-
require 'page-object/elements/
|
55
|
-
require 'page-object/elements/
|
56
|
-
require 'page-object/elements/
|
57
|
-
require 'page-object/elements/
|
58
|
-
require 'page-object/elements/
|
59
|
-
require 'page-object/elements/
|
60
|
-
|
61
|
-
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class << self
|
4
|
+
|
5
|
+
#
|
6
|
+
# method to return the collection of tag_name to class mappings
|
7
|
+
#
|
8
|
+
def tag_to_class
|
9
|
+
@tag_to_class ||= {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def type_to_class
|
13
|
+
@type_to_class ||= {}
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# method to return the element for a tag_name
|
18
|
+
#
|
19
|
+
def element_class_for(tag_name, type=nil)
|
20
|
+
return type_to_class[type.to_sym] if type
|
21
|
+
tag_to_class[tag_name.to_sym] || ::PageObject::Elements::Element
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
require 'page-object/elements/element'
|
30
|
+
require 'page-object/elements/link'
|
31
|
+
require 'page-object/elements/text_field'
|
32
|
+
require 'page-object/elements/date_field'
|
33
|
+
require 'page-object/elements/select_list'
|
34
|
+
require 'page-object/elements/check_box'
|
35
|
+
require 'page-object/elements/button'
|
36
|
+
require 'page-object/elements/radio_button'
|
37
|
+
require 'page-object/elements/div'
|
38
|
+
require 'page-object/elements/table'
|
39
|
+
require 'page-object/elements/table_cell'
|
40
|
+
require 'page-object/elements/table_row'
|
41
|
+
require 'page-object/elements/span'
|
42
|
+
require 'page-object/elements/image'
|
43
|
+
require 'page-object/elements/hidden_field'
|
44
|
+
require 'page-object/elements/form'
|
45
|
+
require 'page-object/elements/text_area'
|
46
|
+
require 'page-object/elements/list_item'
|
47
|
+
require 'page-object/elements/unordered_list'
|
48
|
+
require 'page-object/elements/ordered_list'
|
49
|
+
require 'page-object/elements/option'
|
50
|
+
require 'page-object/elements/heading'
|
51
|
+
require 'page-object/elements/paragraph'
|
52
|
+
require 'page-object/elements/label'
|
53
|
+
require 'page-object/elements/file_field'
|
54
|
+
require 'page-object/elements/area'
|
55
|
+
require 'page-object/elements/canvas'
|
56
|
+
require 'page-object/elements/media'
|
57
|
+
require 'page-object/elements/audio'
|
58
|
+
require 'page-object/elements/video'
|
59
|
+
require 'page-object/elements/bold'
|
60
|
+
require 'page-object/elements/italic'
|
61
|
+
|
62
|
+
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class Area < Element
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
::PageObject::Elements.type_to_class[:area] = ::PageObject::Elements::Area
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class Area < Element
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
::PageObject::Elements.type_to_class[:area] = ::PageObject::Elements::Area
|
8
|
+
end
|
9
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class Audio < Media
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
::PageObject::Elements.type_to_class[:audio] = ::PageObject::Elements::Audio
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class Audio < Media
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
::PageObject::Elements.type_to_class[:audio] = ::PageObject::Elements::Audio
|
8
|
+
end
|
9
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class Bold < Element
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
::PageObject::Elements.tag_to_class[:b] = ::PageObject::Elements::Bold
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class Bold < Element
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
::PageObject::Elements.tag_to_class[:b] = ::PageObject::Elements::Bold
|
8
|
+
end
|
9
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class Button < Element
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
::PageObject::Elements.type_to_class[:submit] = ::PageObject::Elements::Button
|
8
|
-
::PageObject::Elements.type_to_class[:image] = ::PageObject::Elements::Button
|
9
|
-
::PageObject::Elements.type_to_class[:button] = ::PageObject::Elements::Button
|
10
|
-
::PageObject::Elements.type_to_class[:reset] = ::PageObject::Elements::Button
|
11
|
-
end
|
12
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class Button < Element
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
::PageObject::Elements.type_to_class[:submit] = ::PageObject::Elements::Button
|
8
|
+
::PageObject::Elements.type_to_class[:image] = ::PageObject::Elements::Button
|
9
|
+
::PageObject::Elements.type_to_class[:button] = ::PageObject::Elements::Button
|
10
|
+
::PageObject::Elements.type_to_class[:reset] = ::PageObject::Elements::Button
|
11
|
+
end
|
12
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class Canvas < Element
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
::PageObject::Elements.type_to_class[:canvas] = ::PageObject::Elements::Canvas
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class Canvas < Element
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
::PageObject::Elements.type_to_class[:canvas] = ::PageObject::Elements::Canvas
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class CheckBox < Element
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
::PageObject::Elements.type_to_class[:checkbox] = ::PageObject::Elements::CheckBox
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class CheckBox < Element
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
::PageObject::Elements.type_to_class[:checkbox] = ::PageObject::Elements::CheckBox
|
8
|
+
end
|
9
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Elements
|
3
|
-
class Div < Element
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
::PageObject::Elements.tag_to_class[:div] = ::PageObject::Elements::Div
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Elements
|
3
|
+
class Div < Element
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
::PageObject::Elements.tag_to_class[:div] = ::PageObject::Elements::Div
|
8
|
+
end
|
9
|
+
end
|
@@ -1,159 +1,212 @@
|
|
1
|
-
require 'page-object/nested_elements'
|
2
|
-
|
3
|
-
|
4
|
-
module
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
@
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
#
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
#
|
29
|
-
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
#
|
51
|
-
# Keeps checking until the element
|
52
|
-
#
|
53
|
-
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
54
|
-
#
|
55
|
-
def
|
56
|
-
timed_loop(timeout) do |element|
|
57
|
-
element.
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
#
|
99
|
-
#
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
#
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
1
|
+
require 'page-object/nested_elements'
|
2
|
+
|
3
|
+
module PageObject
|
4
|
+
module Elements
|
5
|
+
#
|
6
|
+
# Contains functionality that is common across all elements.
|
7
|
+
#
|
8
|
+
# @see PageObject::Platforms::Watir::Element for the Watir version of all common methods
|
9
|
+
#
|
10
|
+
class Element
|
11
|
+
include ::PageObject::NestedElements
|
12
|
+
|
13
|
+
attr_reader :element
|
14
|
+
|
15
|
+
def initialize(element)
|
16
|
+
@element = element
|
17
|
+
@platform = PageObject::Platforms::Watir::PageObject.new(@element)
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# return true if the element is not enabled
|
22
|
+
#
|
23
|
+
def disabled?
|
24
|
+
not enabled?
|
25
|
+
end
|
26
|
+
|
27
|
+
#
|
28
|
+
# return true if the element exists and is visible
|
29
|
+
#
|
30
|
+
def present?
|
31
|
+
element.present?
|
32
|
+
end
|
33
|
+
|
34
|
+
def drag_and_drop_on(droppable)
|
35
|
+
droppable_native = droppable.kind_of?(PageObject::Elements::Element) ? droppable.element : droppable
|
36
|
+
element.drag_and_drop_on(droppable_native)
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# specify plural form of element
|
41
|
+
#
|
42
|
+
def self.plural_form
|
43
|
+
"#{self.to_s.split('::')[-1].
|
44
|
+
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
45
|
+
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
46
|
+
tr("-", "_").
|
47
|
+
downcase}s"
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# Keeps checking until the element is visible
|
52
|
+
#
|
53
|
+
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
54
|
+
#
|
55
|
+
def check_visible(timeout=::PageObject.default_element_wait)
|
56
|
+
timed_loop(timeout) do |element|
|
57
|
+
element.present?
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# Keeps checking until the element exists
|
63
|
+
#
|
64
|
+
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
65
|
+
#
|
66
|
+
def check_exists(timeout=::PageObject.default_element_wait)
|
67
|
+
timed_loop(timeout) do |element|
|
68
|
+
element.exists?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# compare this element to another to determine if they are equal
|
74
|
+
#
|
75
|
+
def ==(other)
|
76
|
+
other.is_a? self.class and element == other.element
|
77
|
+
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# find the parent element
|
81
|
+
#
|
82
|
+
def parent(opt = {})
|
83
|
+
parent = element.parent(opt)
|
84
|
+
pageobject_wrapper(parent)
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# Return the element that exists at the same level of the DOM
|
89
|
+
# immediately prior to this element
|
90
|
+
#
|
91
|
+
def preceding_sibling(opt = {})
|
92
|
+
sibling = element.preceding_sibling(opt)
|
93
|
+
pageobject_wrapper(sibling)
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Return the element that exists at the same level of the DOM
|
98
|
+
# immediately after this element
|
99
|
+
#
|
100
|
+
def following_sibling(opt={})
|
101
|
+
sibling = element.following_sibling(opt)
|
102
|
+
pageobject_wrapper(sibling)
|
103
|
+
end
|
104
|
+
|
105
|
+
#
|
106
|
+
# Return all elements that are direct children of this element's parent
|
107
|
+
#
|
108
|
+
def siblings(opt={})
|
109
|
+
siblings = element.siblings(opt)
|
110
|
+
siblings.collect {|sibling| pageobject_wrapper(sibling)}
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# Return all elements that are children of this element
|
115
|
+
#
|
116
|
+
def children(opt={})
|
117
|
+
children = element.children(opt)
|
118
|
+
children.collect {|child| pageobject_wrapper(child)}
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
# Return all elements that exist at the same level of the DOM
|
123
|
+
# immediately prior to this element
|
124
|
+
#
|
125
|
+
def preceding_siblings(opt={})
|
126
|
+
siblings = element.preceding_siblings(opt)
|
127
|
+
siblings.collect {|sibling| pageobject_wrapper(sibling)}
|
128
|
+
end
|
129
|
+
|
130
|
+
#
|
131
|
+
# Return all elements that exist at the same level of the DOM
|
132
|
+
# immediately after this element
|
133
|
+
#
|
134
|
+
def following_siblings(opt={})
|
135
|
+
siblings = element.following_siblings(opt)
|
136
|
+
siblings.collect {|sibling| pageobject_wrapper(sibling)}
|
137
|
+
end
|
138
|
+
|
139
|
+
#
|
140
|
+
# Waits until the element is present
|
141
|
+
#
|
142
|
+
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
143
|
+
#
|
144
|
+
def when_present(timeout=::PageObject.default_element_wait)
|
145
|
+
element.wait_until(timeout: timeout, message: "Element not present in #{timeout} seconds", &:present?)
|
146
|
+
self
|
147
|
+
end
|
148
|
+
alias_method :when_visible, :when_present
|
149
|
+
|
150
|
+
#
|
151
|
+
# Waits until the element is not present
|
152
|
+
#
|
153
|
+
# @param [Integer] (defaults to: 5) seconds to wait before
|
154
|
+
# timing out
|
155
|
+
#
|
156
|
+
def when_not_present(timeout=::PageObject.default_element_wait)
|
157
|
+
element.wait_while(timeout: timeout, message: "Element still present in #{timeout} seconds", &:present?)
|
158
|
+
end
|
159
|
+
alias_method :when_not_visible, :when_not_present
|
160
|
+
|
161
|
+
#
|
162
|
+
# Waits until the block returns true
|
163
|
+
#
|
164
|
+
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
165
|
+
# @param [String] the message to display if the event timeouts
|
166
|
+
# @param the block to execute when the event occurs
|
167
|
+
#
|
168
|
+
def wait_until(timeout=::PageObject.default_element_wait, message=nil, &block)
|
169
|
+
element.wait_until(timeout: timeout, message: message, &block)
|
170
|
+
end
|
171
|
+
|
172
|
+
def name
|
173
|
+
element.attribute(:name)
|
174
|
+
end
|
175
|
+
|
176
|
+
# @private
|
177
|
+
# delegate calls to driver element
|
178
|
+
def method_missing(method, *args, &block)
|
179
|
+
if element.respond_to?(method)
|
180
|
+
element.send(method, *args, &block)
|
181
|
+
else
|
182
|
+
super
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def respond_to_missing?(m,*args)
|
187
|
+
element.respond_to?(m) || super
|
188
|
+
end
|
189
|
+
|
190
|
+
protected
|
191
|
+
|
192
|
+
def pageobject_wrapper(watir_object)
|
193
|
+
type = element.type if watir_object.tag_name.to_sym == :input
|
194
|
+
cls = ::PageObject::Elements.element_class_for(watir_object.tag_name, type)
|
195
|
+
cls.new(watir_object.to_subtype)
|
196
|
+
end
|
197
|
+
|
198
|
+
private
|
199
|
+
|
200
|
+
def timed_loop(timeout)
|
201
|
+
end_time = ::Time.now + timeout
|
202
|
+
until ::Time.now > end_time
|
203
|
+
result = yield(self)
|
204
|
+
return result if result
|
205
|
+
sleep 0.5
|
206
|
+
end
|
207
|
+
false
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|