awetestlib 0.1.30-x86-mingw32 → 1.2.4-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +101 -41
  3. data/awetestlib.gemspec +36 -47
  4. data/awetestlib_osx.gemspec +24 -18
  5. data/awetestlib_windows.gemspec +46 -0
  6. data/bin/awetestlib +130 -111
  7. data/bin/awetestlib-driver-setup.rb +0 -2
  8. data/bin/awetestlib-helpers.rb +43 -30
  9. data/lib/awetestlib.rb +196 -20
  10. data/lib/awetestlib/command_line.rb +44 -0
  11. data/lib/awetestlib/html_report.rb +57 -50
  12. data/lib/awetestlib/logging.rb +242 -171
  13. data/lib/awetestlib/regression/awetest_dsl.rb +4240 -0
  14. data/lib/awetestlib/regression/browser.rb +514 -397
  15. data/lib/awetestlib/regression/date_and_time.rb +280 -0
  16. data/lib/awetestlib/regression/drag_and_drop.rb +24 -0
  17. data/lib/awetestlib/regression/find.rb +70 -43
  18. data/lib/awetestlib/regression/legacy.rb +1 -1
  19. data/lib/awetestlib/regression/mobile.rb +293 -0
  20. data/lib/awetestlib/regression/reporting.rb +298 -0
  21. data/lib/awetestlib/regression/runner.rb +156 -200
  22. data/lib/awetestlib/regression/tables.rb +117 -7
  23. data/lib/awetestlib/regression/test_data.rb +354 -0
  24. data/lib/awetestlib/regression/user_input.rb +179 -93
  25. data/lib/awetestlib/regression/utilities.rb +755 -286
  26. data/lib/awetestlib/regression/validations.rb +325 -115
  27. data/lib/awetestlib/regression/waits.rb +60 -133
  28. data/lib/awetestlib/runner.rb +5 -2
  29. data/lib/version.rb +11 -2
  30. data/setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb +109 -49
  31. data/setup_samples/sample_mobile_app/features/support/env.rb +1 -1
  32. data/test/google_search2.rb +7 -6
  33. data/test/popup_child_0.rb +13 -0
  34. data/test/popup_child_1.rb +33 -0
  35. data/test/watir_no_require.rb +13 -0
  36. data/test/watir_with_require.rb +16 -0
  37. data/test/zoho_exercise.rb +8 -8
  38. metadata +216 -303
  39. data/AwetestLib Instructions.rtf +0 -0
  40. data/awetestlib.windows.gemspec +0 -42
  41. data/lib/patches/README +0 -2
  42. data/lib/patches/firewatir.rb +0 -106
  43. data/lib/patches/watir.rb +0 -175
@@ -136,58 +136,70 @@ module Awetestlib
136
136
  # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
137
137
  # @param [String] desc Contains a message or description intended to appear in the log and/or report output
138
138
  # @return [Boolean] Returns true if the element is enabled.
139
- def enabled?(browser, element, how, what, desc = '')
140
- #TODO: handle identification of element with value as well as other attribute. see exists?
141
- msg = build_message("#{element.to_s.titlecase} by #{how}=>'#{what}' is enabled.}", desc)
142
- case element
143
- when :textfield, :textarea, :text_area, :text_field
144
- rtrn = browser.text_field(how, what).enabled? and not browser.text_field(how, what).readonly?
145
- when :select_list, :selectlist
146
- rtrn = browser.select_list(how, what).enabled?
147
- else
148
- rtrn = browser.element(how, what).enabled?
149
- end
150
- if rtrn
151
- passed_to_log("#{msg}")
139
+ #def enabled?(browser, element, how, what, desc = '')
140
+ # #TODO: Webdriver does not define this at element level, only for specific tags
141
+ # #TODO: handle identification of element with value as well as other attribute. see exists?
142
+ # msg = build_message("#{element.to_s.titlecase} by #{how}=>'#{what}' is enabled.}", desc)
143
+ # case element
144
+ # when :textfield, :textarea, :text_area, :text_field
145
+ # rtrn = browser.text_field(how, what).enabled? and not browser.text_field(how, what).readonly?
146
+ # when :select_list, :selectlist
147
+ # rtrn = browser.select_list(how, what).enabled?
148
+ # else
149
+ # rtrn = browser.element(how, what).enabled?
150
+ # end
151
+ # if rtrn
152
+ # passed_to_log("#{msg}")
153
+ # true
154
+ # else
155
+ # failed_to_log("#{msg}")
156
+ # end
157
+ # rtrn
158
+ #rescue
159
+ # failed_to_log(unable_to(msg, false, true))
160
+ #end
161
+
162
+ #alias validate_enabled enabled?
163
+
164
+ def expected_color?(container, element, how, what, style, expected_color, desc = '')
165
+ #TODO: check that style is a color style
166
+ msg = build_message("Color of #{element} #{how}=>'#{what}' #{style} is #{expected_color}", desc)
167
+ code = build_webdriver_fetch(element, how, what)
168
+ actual_color = eval("#{code}.style('#{style}')")
169
+ if actual_color == expected_color
170
+ passed_to_log(msg)
152
171
  true
153
172
  else
154
- failed_to_log("#{msg}")
173
+ failed_to_log(msg)
155
174
  end
156
- rtrn
157
175
  rescue
158
176
  failed_to_log(unable_to(msg, false, true))
159
177
  end
160
178
 
161
- alias validate_enabled enabled?
179
+ def disablement(container, should_be, element, how, what, desc = '')
180
+ if should_be
181
+ disabled?(container, element, how, what, desc)
182
+ else
183
+ enabled?(container, element, how, what, desc)
184
+ end
185
+ rescue
186
+ failed_to_log(unable_to(desc, false, true))
187
+ end
162
188
 
163
189
  # Verify that a DOM element is disabled.
164
190
  # @param (see #enabled?)
165
191
  # @return [Boolean] Returns true if the element is disabled.
166
- def disabled?(browser, element, how, what, desc = '')
167
- #TODO: handle identification of element with value as well as other attribute. see exists?
168
- msg = build_message("#{element.to_s.titlecase} by #{how}=>'#{what}' is disabled.", desc)
169
- case element
170
- when :textfield, :textarea, :text_area, :text_field
171
- rtrn = browser.text_field(how, what).disabled? ||
172
- browser.text_field(how, what).readonly?
173
- when :select_list, :selectlist
174
- rtrn = browser.select_list(how, what).disabled?
175
- when :checkbox
176
- rtrn = browser.checkbox(how, what).disabled?
177
- when :radio
178
- rtrn = browser.radio(how, what).disabled?
179
- when :button
180
- rtrn = browser.button(how, what).disabled?
181
- else
182
- rtrn = browser.element(how, what).disabled?
183
- end
184
- if rtrn
185
- passed_to_log("#{msg}")
192
+ def disabled?(container, element, how, what, desc = '', value = nil)
193
+ value, desc, options = capture_value_desc(value, desc) # for backwards compatibility
194
+ msg2 = value ? "and value=>'#{value}' " : nil
195
+ msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'is disabled.', desc)
196
+ code = build_webdriver_fetch(element, how, what, options)
197
+ if eval("#{code}.disabled?")
198
+ passed_to_log(msg)
186
199
  true
187
200
  else
188
- failed_to_log("#{msg}")
201
+ failed_to_log(msg)
189
202
  end
190
- rtrn
191
203
  rescue
192
204
  failed_to_log(unable_to(msg, false, true))
193
205
  end
@@ -195,30 +207,104 @@ module Awetestlib
195
207
  alias validate_not_enabled disabled?
196
208
  alias validate_disabled disabled?
197
209
 
210
+ def not_disabled?(container, element, how, what, desc = '', value = nil)
211
+ value, desc, options = capture_value_desc(value, desc) # for backwards compatibility
212
+ msg2 = value ? "and value=>'#{value}' " : nil
213
+ msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'is enabled.', desc)
214
+ code = build_webdriver_fetch(element, how, what, options)
215
+ if eval("#{code}.disabled?")
216
+ failed_to_log(msg)
217
+ else
218
+ passed_to_log(msg)
219
+ true
220
+ end
221
+ rescue
222
+ failed_to_log(unable_to(msg, false, true))
223
+ end
224
+
225
+ alias enabled? not_disabled?
226
+ alias validate_enabled not_disabled?
227
+
228
+ def element_disablement(target, disabled, desc = '')
229
+ #TODO: Is this really necessary?
230
+ is_disabled = target.disabled?
231
+ disablement = false
232
+ should_be = disabled ? true : false
233
+ msg = build_message("#{method_to_title(__method__)}", "should be #{should_be}", "is #{is_disabled}", desc)
234
+ if should_be == is_disabled
235
+ passed_to_log(msg)
236
+ disablement = true
237
+ else
238
+ failed_to_log(msg)
239
+ end
240
+ [is_disabled, disablement]
241
+ rescue
242
+ failed_to_log(unable_to(msg, false, true))
243
+ end
244
+
245
+ def presence(container, should_be, element, how, what, desc = '')
246
+ if should_be
247
+ is_present?(container, element, how, what, desc)
248
+ else
249
+ not_present?(container, element, how, what, desc)
250
+ end
251
+ rescue
252
+ failed_to_log(unable_to(desc, false, true))
253
+ end
254
+
255
+ def is_present?(container, element, how, what, value = nil, desc = '')
256
+ value, desc, options = capture_value_desc(value, desc) # for backwards compatibility
257
+ msg2 = value ? "and value=>'#{value}' " : nil
258
+ msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'is present.', desc)
259
+ code = build_webdriver_fetch(element, how, what, options)
260
+ if eval("#{code}.present?")
261
+ passed_to_log(msg)
262
+ true
263
+ else
264
+ failed_to_log(msg)
265
+ end
266
+ rescue
267
+ failed_to_log(unable_to(msg, false, true))
268
+ end
269
+
270
+ def not_present?(container, element, how, what, value = nil, desc = '')
271
+ value, desc, options = capture_value_desc(value, desc) # for backwards compatibility
272
+ msg2 = value ? "and value=>'#{value}' " : nil
273
+ msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'is not present.', desc)
274
+ code = build_webdriver_fetch(element, how, what, options)
275
+ if eval("#{code}.exists?")
276
+ failed_to_log(msg)
277
+ else
278
+ passed_to_log(msg)
279
+ true
280
+ end
281
+ rescue
282
+ failed_to_log(unable_to(msg, false, true))
283
+ end
284
+
285
+ def visibility(container, should_be, element, how, what, desc = '')
286
+ msg = build_message(desc)
287
+ if should_be
288
+ visible?(container, element, how, what, desc)
289
+ else
290
+ not_visible?(container, element, how, what, desc)
291
+ end
292
+ rescue
293
+ failed_to_log(unable_to(desc, false, true))
294
+ end
295
+
198
296
  # Verify that a DOM element is visible.
199
297
  # @param (see #enabled?)
200
298
  # @return [Boolean] Returns true if the element is visible.
201
- def visible?(browser, element, how, what, desc = '')
202
- #TODO: handle identification of element with value as well as other attribute. see exists?
203
- msg = build_message("#{element.to_s.titlecase} #{how}=>'#{what}' is visible.", desc)
204
- rtrn = false
205
- case how
206
- when :index
207
- target = get_element(browser, element, how, what)
208
- if target.visible?
209
- rtrn = true
210
- end
211
- else
212
- if browser.element(how, what).visible?
213
- rtrn = true
214
- end
215
- end
216
- if rtrn
299
+ def visible?(container, element, how, what, desc = '')
300
+ msg = build_message("#{__method__.to_s.titleize}: #{element.to_s.titleize} #{how}=>'#{what}'", desc)
301
+ code = build_webdriver_fetch(element, how, what)
302
+ if eval("#{code}.visible?")
217
303
  passed_to_log("#{msg}")
304
+ true
218
305
  else
219
306
  failed_to_log("#{msg}")
220
307
  end
221
- rtrn
222
308
  rescue
223
309
  failed_to_log(unable_to(msg, false, true))
224
310
  end
@@ -228,27 +314,15 @@ module Awetestlib
228
314
  # Verify that a DOM element is not visible.
229
315
  # @param (see #enabled?)
230
316
  # @return [Boolean] Returns true if the element is not visible.
231
- def not_visible?(browser, element, how, what, desc = '')
232
- #TODO: handle identification of element with value as well as other attribute. see exists?
233
- msg = build_message("#{element.to_s.titlecase} #{how}=>'#{what}' is not visible.", desc)
234
- rtrn = false
235
- case how
236
- when :index
237
- target = get_element(browser, element, how, what)
238
- if not target.visible?
239
- rtrn = true
240
- end
241
- else
242
- if not browser.element(how, what).visible?
243
- rtrn = true
244
- end
245
- end
246
- if rtrn
247
- passed_to_log("#{msg}")
248
- else
317
+ def not_visible?(container, element, how, what, desc = '')
318
+ msg = build_message("#{__method__.to_s.titleize}: #{element.to_s.titleize} #{how}=>'#{what}'", desc)
319
+ code = build_webdriver_fetch(element, how, what)
320
+ if eval("#{code}.visible?")
249
321
  failed_to_log("#{msg}")
322
+ else
323
+ passed_to_log("#{msg}")
324
+ true
250
325
  end
251
- rtrn
252
326
  rescue
253
327
  failed_to_log(unable_to(msg, false, true))
254
328
  end
@@ -298,6 +372,16 @@ module Awetestlib
298
372
  alias checkbox_checked? checked?
299
373
  alias checkbox_set? checked?
300
374
 
375
+ def existence(container, should_be, element, how, what, desc = '')
376
+ if should_be
377
+ exists?(container, element, how, what, desc)
378
+ else
379
+ does_not_exist?(container, element, how, what, desc)
380
+ end
381
+ rescue
382
+ failed_to_log(unable_to(desc, false, true))
383
+ end
384
+
301
385
  # Verify that a DOM element exists on the page.
302
386
  # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
303
387
  # @param [Symbol] how The element attribute used to identify the specific element.
@@ -307,20 +391,16 @@ module Awetestlib
307
391
  # @param [String, Regexp] value A string or a regular expression to be found in the value attribute of the element.
308
392
  # @param [String] desc Contains a message or description intended to appear in the log and/or report output
309
393
  # @return [Boolean] True if the element exists.
310
- def exists?(browser, element, how, what, value = nil, desc = '')
311
- msg2 = "and value=>'#{value}' " if value
312
- msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'exists.', desc)
313
- case element
314
- when :link
315
- bool = browser.link(how, what).exists?
316
- else
317
- bool = browser.element(how, what).exists?
318
- end
319
- if bool
320
- passed_to_log("#{msg}? #{desc}")
394
+ def exists?(container, element, how, what, value = nil, desc = '')
395
+ value, desc, options = capture_value_desc(value, desc) # for backwards compatibility
396
+ msg2 = value ? "and value=>'#{value}' " : nil
397
+ msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'exists.', desc)
398
+ code = build_webdriver_fetch(element, how, what, options)
399
+ if eval("#{code}.exists?")
400
+ passed_to_log(msg)
321
401
  true
322
402
  else
323
- failed_to_log("#{msg}? #{desc} [#{get_callers(1)}]")
403
+ failed_to_log(msg)
324
404
  end
325
405
  rescue
326
406
  failed_to_log(unable_to(msg, false, true))
@@ -329,16 +409,12 @@ module Awetestlib
329
409
  # Verify that a DOM element does not exist on the page.
330
410
  # @param (see #exists?)
331
411
  # @return [Boolean] True if the element does not exist.
332
- def does_not_exist?(browser, element, how, what, value = nil, desc = '')
333
- msg2 = "and value=>'#{value}' " if value
334
- msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'does not exist.', desc)
335
- case element
336
- when :link
337
- bool = browser.link(how, what).exists?
338
- else
339
- bool = browser.element(how, what).exists?
340
- end
341
- if bool
412
+ def does_not_exist?(container, element, how, what, value = nil, desc = '')
413
+ value, desc, options = capture_value_desc(value, desc) # for backwards compatibility
414
+ msg2 = value ? "and value=>'#{value}' " : nil
415
+ msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'does not exist.', desc)
416
+ code = build_webdriver_fetch(element, how, what, options)
417
+ if eval("#{code}.exists?")
342
418
  failed_to_log(msg)
343
419
  else
344
420
  passed_to_log(msg)
@@ -649,9 +725,9 @@ module Awetestlib
649
725
  # @param [String, Regexp] expected A string or regular expression which must be matched in the value of the text field
650
726
  # @param [String] desc Contains a message or description intended to appear in the log and/or report output
651
727
  # @return [Boolean] Returns true if the *expected* is matched in the value of the text field.
652
- def textfield_contains?(browser, how, what, expected, desc = '')
728
+ def textfield_contains?(container, how, what, expected, desc = '')
653
729
  msg = build_message("Text field #{how}=>#{what} contains '#{expected}'.", desc)
654
- contents = browser.text_field(how, what).value
730
+ contents = container.text_field(how, what).when_present.value
655
731
  if contents =~ /#{expected}/
656
732
  passed_to_log(msg)
657
733
  true
@@ -659,7 +735,7 @@ module Awetestlib
659
735
  failed_to_log("#{msg} Contents: '#{contents}'")
660
736
  end
661
737
  rescue
662
- failed_to_log(unable_to)
738
+ failed_to_log(unable_to('', false, true))
663
739
  end
664
740
 
665
741
  # Verify that a text field (also text area), identified by *how* and *what*, is empty.
@@ -804,32 +880,32 @@ module Awetestlib
804
880
  end
805
881
  end
806
882
 
807
- def validate_text(browser, ptrn, desc = '', skip_fail = false, skip_sleep = false)
808
- cls = browser.class.to_s
883
+ def validate_text(container, ptrn, desc = '', skip_fail = false, skip_sleep = false)
884
+ cls = container.class.to_s
809
885
  cls.gsub!('Watir::', '')
810
886
  cls.gsub!('IE', 'Browser')
811
- msg = build_message("#{cls} text contains '#{ptrn}'.", desc)
887
+ msg = build_message("#{cls} text contains '#{ptrn}'.", desc)
812
888
  if ptrn.is_a?(Regexp)
813
889
  target = ptrn
814
890
  else
815
891
  target = Regexp.new(Regexp.escape(ptrn))
816
892
  end
817
- sleep_for(2) unless skip_sleep
818
- myText = browser.text
819
- if not myText.match(target)
820
- sleep_for(2) unless skip_sleep #TODO try a wait_until here?
821
- myText = browser.text
893
+ if container.respond_to?(:wait)
894
+ container.wait
895
+ elsif container.respond_to?(:wait_until_present)
896
+ container.wait_until_present
897
+ else
898
+ sleep(3)
822
899
  end
823
- if myText.match(target)
900
+ if container.text.match(target)
824
901
  passed_to_log("#{msg}")
825
902
  true
826
903
  else
827
904
  if skip_fail
828
905
  debug_to_log("#{cls} text does not contain the text: '#{ptrn}'. #{desc} (Fail suppressed)")
829
906
  else
830
- failed_to_log("#{msg}")
907
+ failed_to_log(msg)
831
908
  end
832
- #debug_to_log("\n#{myText}")
833
909
  end
834
910
  rescue
835
911
  failed_to_log(unable_to)
@@ -963,14 +1039,15 @@ module Awetestlib
963
1039
  failed_to_log(unable_to)
964
1040
  end
965
1041
 
966
- def validate_selected_options(browser, how, what, list, desc = '')
967
- select_list = browser.select_list(how, what)
968
- selected = select_list.selected_options.sort
1042
+ def validate_selected_options(browser, how, what, list, desc = '', which = :text)
1043
+ selected_options = browser.select_list(how, what).selected_options.dup
1044
+ selected = extract_selected(selected_options, which)
1045
+ sorted_list = list.dup.sort
969
1046
  if list.is_a?(Array)
970
- if selected == list.sort
1047
+ if selected == sorted_list
971
1048
  passed_to_log("Expected options [#{list.sort}] are selected [#{selected}]. #{desc}")
972
1049
  else
973
- failed_to_log("Selected options [#{selected}] do not match expected [#{list.sort}]. #{desc}")
1050
+ failed_to_log("Selected options [#{selected}] do not match expected [#{sorted_list}]. #{desc}")
974
1051
  true
975
1052
  end
976
1053
  else
@@ -1073,6 +1150,139 @@ module Awetestlib
1073
1150
  failed_to_log(unable_to)
1074
1151
  end
1075
1152
 
1153
+ def attribute_contains?(container, element, how, what, attr_name, expected, desc = '')
1154
+ msg = build_message("Element #{element} :#{how}=>#{what}", "attribute '#{attr_name}", "contains '#{expected}'.", desc)
1155
+ if container.element(how, what).attribute_value(attr_name).contains(expected)
1156
+ passed_to_log(msg)
1157
+ true
1158
+ else
1159
+ failed_to_log(msg)
1160
+ end
1161
+ rescue
1162
+ failed_to_log(unable_to('', false, true))
1163
+ end
1164
+
1165
+ def attribute_does_not_contain?(container, element, how, what, attr_name, expected, desc = '')
1166
+ msg = build_message("Element #{element} :#{how}=>#{what}", "attribute '#{attr_name}", "does not contain '#{expected}'.", desc)
1167
+ if container.element(how, what).attribute_value(attr_name).contains(expected)
1168
+ failed_to_log(msg)
1169
+ else
1170
+ passed_to_log(msg)
1171
+ true
1172
+ end
1173
+ rescue
1174
+ failed_to_log(unable_to('', false, true))
1175
+ end
1176
+
1177
+ def attribute_equals?(container, element, how, what, attr_name, expected, desc = '')
1178
+ msg = build_message("Element #{element} :#{how}=>#{what}", "attribute '#{attr_name}", "equals '#{expected}'.", desc)
1179
+ actual = container.element(how, what).attribute_value(attr_name)
1180
+ if actual == expected
1181
+ passed_to_log(msg)
1182
+ true
1183
+ else
1184
+ failed_to_log("#{msg} Found '#{actual}'")
1185
+ end
1186
+ rescue
1187
+ failed_to_log(unable_to('', false, true))
1188
+ end
1189
+
1190
+ def attribute_does_not_equal?(container, element, how, what, attr_name, expected, desc = '')
1191
+ msg = build_message("Element #{element} :#{how}=>#{what}", "attribute '#{attr_name}", "does not equal '#{expected}'.", desc)
1192
+ if container.element(how, what).attribute_value(attr_name) == expected
1193
+ failed_to_log(msg)
1194
+ else
1195
+ passed_to_log(msg)
1196
+ true
1197
+ end
1198
+ rescue
1199
+ failed_to_log(unable_to('', false, true))
1200
+ end
1201
+
1202
+ def element_attribute_equals?(element, attr_name, expected, desc = '')
1203
+ msg = build_message("#{element.tag_name.capitalize}", "attribute '#{attr_name}'", "equals '#{expected}'.", desc)
1204
+ actual = element.attribute_value(attr_name)
1205
+ if actual == expected
1206
+ passed_to_log(msg)
1207
+ true
1208
+ else
1209
+ failed_to_log("#{msg} Found '#{actual}'")
1210
+ end
1211
+ rescue
1212
+ failed_to_log(unable_to('', false, true))
1213
+ end
1214
+
1215
+ def element_attribute_does_not_equal?(element, attr_name, expected, desc = '')
1216
+ msg = build_message("#{element.tag_name.capitalize}", "attribute '#{attr_name}'", "does not equal '#{expected}'.", desc)
1217
+ if element.attribute_value(attr_name) == expected
1218
+ failed_to_log(msg)
1219
+ else
1220
+ passed_to_log(msg)
1221
+ true
1222
+ end
1223
+ rescue
1224
+ failed_to_log(unable_to('', false, true))
1225
+ end
1226
+
1227
+ def element_attribute_contains?(element, attribute, expected, desc = '')
1228
+ msg = build_message("#{element.tag_name.capitalize}", "attribute '#{attribute}'","contains '#{expected}'.", desc)
1229
+ if element.attribute_value(attribute).include?(expected)
1230
+ passed_to_log(msg)
1231
+ true
1232
+ else
1233
+ failed_to_log(msg)
1234
+ end
1235
+ rescue
1236
+ failed_to_log(unable_to('', false, true))
1237
+ end
1238
+
1239
+ def element_attribute_does_not_contain?(element, attribute, expected, desc = '')
1240
+ msg = build_message("#{element.tag_name.capitalize}", "attribute '#{attribute}'","does not contain '#{expected}'.", desc)
1241
+ if element.attribute_value(attribute).include?(expected)
1242
+ failed_to_log(msg)
1243
+ else
1244
+ passed_to_log(msg)
1245
+ true
1246
+ end
1247
+ rescue
1248
+ failed_to_log(unable_to('', false, true))
1249
+ end
1250
+
1251
+ def contains_text?(container, element, how, what, expected, desc = '')
1252
+ msg = build_message("Element #{element} :#{how}=>#{what} contains '#{expected}'.", desc)
1253
+ code = build_webdriver_fetch(element, how, what)
1254
+ target = eval(code)
1255
+ if target
1256
+ text = target.text
1257
+ if expected and expected.length > 0
1258
+ rgx = Regexp.new(Regexp.escape(expected))
1259
+ if text =~ rgx
1260
+ passed_to_log(msg)
1261
+ true
1262
+ else
1263
+ debug_to_log("exp: [#{expected.gsub(' ', '^')}]")
1264
+ debug_to_log("act: [#{text.gsub(' ', '^')}]")
1265
+ failed_to_log("#{msg} Found '#{text}'. #{desc}")
1266
+ end
1267
+ else
1268
+ if text.length > 0
1269
+ debug_to_log("exp: [#{expected.gsub(' ', '^')}]")
1270
+ debug_to_log("act: [#{text.gsub(' ', '^')}]")
1271
+ failed_to_log("#{msg} Found '#{text}'. #{desc}")
1272
+ else
1273
+ passed_to_log(msg)
1274
+ true
1275
+ end
1276
+ end
1277
+ end
1278
+ rescue
1279
+ failed_to_log(unable_to(msg, false, true))
1280
+ end
1281
+
1282
+ def directory_exists?(directory)
1283
+ File.directory?(directory)
1284
+ end
1285
+
1076
1286
  # @!endgroup Core
1077
1287
 
1078
1288
  # @!group Deprecated