File tree 1 file changed +36
-1
lines changed
1 file changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -167,8 +167,43 @@ def set_wait timeout=$default_wait
167
167
$driver. manage . timeouts . implicit_wait = timeout
168
168
end
169
169
170
+ # Returns the default client side wait.
171
+ # This value is independent of what the server is using
172
+ # @return [Integer]
173
+ def get_wait
174
+ $default_wait
175
+ end
176
+
177
+ # Returns existance of element.
178
+ #
179
+ # Example:
180
+ #
181
+ # exists { button('sign in') } ? puts('true') : puts('false')
182
+ #
183
+ # @return [Boolean]
184
+ def exists &search_block
185
+ pre_check = 0
186
+ post_check = $default_wait
187
+
188
+ set_wait pre_check # set wait to zero
189
+
190
+ # the element exists unless an error is raised.
191
+ exists = true
192
+
193
+ begin
194
+ search_block . call # search for element
195
+ rescue
196
+ exists = false # error means it's not there
197
+ end
198
+
199
+ # restore wait
200
+ set_wait post_check
201
+
202
+ return exists
203
+ end
204
+
170
205
# The same as $driver.execute_script
171
- # @return the object returned by execute_script
206
+ # @return [Object] the object returned by execute_script
172
207
def execute_script script , *args
173
208
$driver. execute_script script , *args
174
209
end
You can’t perform that action at this time.
0 commit comments