page-object 2.2.3 → 2.3.1

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