testcentricity 2.3.16.1 → 2.3.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53f516f04ab690c0e7bf993f86241902d74b6b4a
4
- data.tar.gz: 7b922146ab2ded68ae406d56ca35e2e17d51ebf2
3
+ metadata.gz: 254dae3895ab2f916930ce27ec170ae272e8aa53
4
+ data.tar.gz: 1c34b8a232896f140423225c73e97f9be2a1603a
5
5
  SHA512:
6
- metadata.gz: 36ff52b324fcc5e202607f9c376a2e9325064116030af4feff6c53c95f5ce04c42a84fb5b36037580d8e0fb5ed54e011b255869a1d16482d7bfefc723b391903
7
- data.tar.gz: 3fcf2ef5f82df0980e685ac1098755b51b1e1c2eb622d2bd97ca7840c668e0ab0be5a3bdf4934e90c4ad4a2955834230c3e8c1babbba5edaf67f01bcd8044abb
6
+ metadata.gz: 7a0e9e601a675a2c3118c8bd4840bf7c1957e415203e5eca4a57d623a8e74671d7a7820f6280ac4e2d72fec999ce4e523fbc3bb9dc61faaedbd26587a3bc2b55
7
+ data.tar.gz: 4bb9432870f15132fca627333747c7da429b38b924252946c11531ba8764f64050547ecb3764b525e0cc74d04f63b4fd0f5dbb433d013a9560590f7a4ad0afc6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- testcentricity (3.0.1)
4
+ testcentricity (2.3.16.1)
5
5
  appium_lib
6
6
  browserstack-local
7
7
  capybara (>= 2.15, < 3.0)
data/README.md CHANGED
@@ -28,6 +28,11 @@ hosted instances of Chrome, Firefox, Safari, and IE web browsers.
28
28
 
29
29
 
30
30
  ## What's New
31
+ ###Version 2.3.17
32
+
33
+ * Added `List.wait_until_item_count_is` and `List.wait_until_item_count_changes` methods.
34
+ * `UIElement.wait_until_value_is` and `List.wait_until_item_count_is` methods now accept comparison hash.
35
+
31
36
  ###Version 2.3.16
32
37
 
33
38
  * Added `PageSection.double_click`, `PageObject.right_click`, and `PageObject.send_keys` methods.
@@ -18,11 +18,7 @@ module TestCentricity
18
18
  Environ.device_name = ENV['APP_DEVICE']
19
19
  Environ.device_os = ENV['APP_PLATFORM_NAME']
20
20
  Environ.device_orientation = ENV['ORIENTATION'] if ENV['ORIENTATION']
21
- if ENV['UDID']
22
- Environ.device = :device
23
- else
24
- Environ.device = :simulator
25
- end
21
+ ENV['UDID'] ? Environ.device = :device : Environ.device = :simulator
26
22
  end
27
23
  @running = false
28
24
  end
@@ -60,11 +56,9 @@ module TestCentricity
60
56
  if Environ.is_android?
61
57
  capabilities[:app] = Environ.current.android_apk_path
62
58
  elsif Environ.is_ios?
63
- if Environ.is_device?
64
- capabilities[:app] = Environ.current.ios_ipa_path
65
- else
66
- capabilities[:app] = Environ.current.ios_app_path
67
- end
59
+ Environ.is_device? ?
60
+ capabilities[:app] = Environ.current.ios_ipa_path :
61
+ capabilities[:app] = Environ.current.ios_app_path
68
62
  end
69
63
  end
70
64
 
File without changes
@@ -109,8 +109,8 @@ module TestCentricity
109
109
  class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppAlert.new("#{element_name}", self, #{locator}, :page);end))
110
110
  end
111
111
 
112
- def self.section(section_name, class_name)
113
- class_eval(%(def #{section_name};@#{section_name} ||= #{class_name}.new("#{section_name}", self, :page);end))
112
+ def self.section(section_name, class_name, locator = 0)
113
+ class_eval(%(def #{section_name};@#{section_name} ||= #{class_name}.new("#{section_name}", self, #{locator}, :page);end))
114
114
  end
115
115
 
116
116
  def self.sections(section_hash)
@@ -183,6 +183,8 @@ module TestCentricity
183
183
  puts "#{ui_object.get_name} - #{property} = #{state}" if ENV['DEBUG']
184
184
 
185
185
  case property
186
+ when :class
187
+ actual = ui_object.get_attribute(:class)
186
188
  when :exists
187
189
  actual = ui_object.exists?
188
190
  when :enabled
@@ -222,49 +224,8 @@ module TestCentricity
222
224
  when :y
223
225
  actual = ui_object.y_loc
224
226
  end
225
-
226
- if state.is_a?(Hash) && state.length == 1
227
- error_msg = "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property to"
228
- state.each do |key, value|
229
- case key
230
- when :lt, :less_than
231
- ExceptionQueue.enqueue_exception("#{error_msg} be less than #{value} but found '#{actual}'") unless actual < value
232
- when :lt_eq, :less_than_or_equal
233
- ExceptionQueue.enqueue_exception("#{error_msg} be less than or equal to #{value} but found '#{actual}'") unless actual <= value
234
- when :gt, :greater_than
235
- ExceptionQueue.enqueue_exception("#{error_msg} be greater than #{value} but found '#{actual}'") unless actual > value
236
- when :gt_eq, :greater_than_or_equal
237
- ExceptionQueue.enqueue_exception("#{error_msg} be greater than or equal to #{value} but found '#{actual}'") unless actual >= value
238
- when :starts_with
239
- ExceptionQueue.enqueue_exception("#{error_msg} start with '#{value}' but found '#{actual}'") unless actual.start_with?(value)
240
- when :ends_with
241
- ExceptionQueue.enqueue_exception("#{error_msg} end with '#{value}' but found '#{actual}'") unless actual.end_with?(value)
242
- when :contains
243
- ExceptionQueue.enqueue_exception("#{error_msg} contain '#{value}' but found '#{actual}'") unless actual.include?(value)
244
- when :not_contains, :does_not_contain
245
- ExceptionQueue.enqueue_exception("#{error_msg} not contain '#{value}' but found '#{actual}'") if actual.include?(value)
246
- when :not_equal
247
- ExceptionQueue.enqueue_exception("#{error_msg} not equal '#{value}' but found '#{actual}'") if actual == value
248
- when :like, :is_like
249
- actual_like = actual.delete("\n")
250
- actual_like = actual_like.delete("\r")
251
- actual_like = actual_like.delete("\t")
252
- actual_like = actual_like.delete(' ')
253
- actual_like = actual_like.downcase
254
- expected = value.delete("\n")
255
- expected = expected.delete("\r")
256
- expected = expected.delete("\t")
257
- expected = expected.delete(' ')
258
- expected = expected.downcase
259
- ExceptionQueue.enqueue_exception("#{error_msg} be like '#{value}' but found '#{actual}'") unless actual_like.include?(expected)
260
- when :translate
261
- expected = I18n.t(value)
262
- ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) translated #{property} property")
263
- end
264
- end
265
- else
266
- ExceptionQueue.enqueue_assert_equal(state, actual, "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property")
267
- end
227
+ error_msg = "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property to"
228
+ ExceptionQueue.enqueue_comparison(state, actual, error_msg)
268
229
  end
269
230
  end
270
231
  rescue ObjectNotFoundError => e
@@ -286,6 +247,7 @@ module TestCentricity
286
247
  when :checkbox
287
248
  data_field.set_checkbox_state(data_param.to_bool)
288
249
  when :textfield
250
+ data_field.clear
289
251
  data_field.set("#{data_param}\t")
290
252
  end
291
253
  end
@@ -10,17 +10,17 @@ module TestCentricity
10
10
  attr_accessor :parent_list
11
11
  attr_accessor :list_index
12
12
 
13
- def initialize(name, parent, context)
13
+ def initialize(name, parent, locator, context)
14
14
  @name = name
15
15
  @parent = parent
16
+ @locator = locator
16
17
  @context = context
17
18
  @parent_list = nil
18
19
  @list_index = nil
19
- @locator = nil
20
20
  end
21
21
 
22
22
  def get_locator
23
- @locator = section_locator
23
+ @locator = section_locator if @locator.zero? && defined?(section_locator)
24
24
  locators = []
25
25
  if @context == :section && !@parent.nil?
26
26
  locators.push(@parent.get_locator)
@@ -170,8 +170,8 @@ module TestCentricity
170
170
  class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppAlert.new("#{element_name}", self, #{locator}, :page);end))
171
171
  end
172
172
 
173
- def self.section(section_name, class_name)
174
- class_eval(%(def #{section_name};@#{section_name} ||= #{class_name}.new("#{section_name}", self, :section);end))
173
+ def self.section(section_name, class_name, locator = 0)
174
+ class_eval(%(def #{section_name};@#{section_name} ||= #{class_name}.new("#{section_name}", self, #{locator}, :section);end))
175
175
  end
176
176
 
177
177
  def self.sections(section_hash)
@@ -301,6 +301,8 @@ module TestCentricity
301
301
  puts "#{ui_object.get_name} - #{property} = #{state}" if ENV['DEBUG']
302
302
 
303
303
  case property
304
+ when :class
305
+ actual = ui_object.get_attribute(:class)
304
306
  when :exists
305
307
  actual = ui_object.exists?
306
308
  when :enabled
@@ -340,49 +342,8 @@ module TestCentricity
340
342
  when :y
341
343
  actual = ui_object.y_loc
342
344
  end
343
-
344
- if state.is_a?(Hash) && state.length == 1
345
- error_msg = "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property to"
346
- state.each do |key, value|
347
- case key
348
- when :lt, :less_than
349
- ExceptionQueue.enqueue_exception("#{error_msg} be less than #{value} but found '#{actual}'") unless actual < value
350
- when :lt_eq, :less_than_or_equal
351
- ExceptionQueue.enqueue_exception("#{error_msg} be less than or equal to #{value} but found '#{actual}'") unless actual <= value
352
- when :gt, :greater_than
353
- ExceptionQueue.enqueue_exception("#{error_msg} be greater than #{value} but found '#{actual}'") unless actual > value
354
- when :gt_eq, :greater_than_or_equal
355
- ExceptionQueue.enqueue_exception("#{error_msg} be greater than or equal to #{value} but found '#{actual}'") unless actual >= value
356
- when :starts_with
357
- ExceptionQueue.enqueue_exception("#{error_msg} start with '#{value}' but found '#{actual}'") unless actual.start_with?(value)
358
- when :ends_with
359
- ExceptionQueue.enqueue_exception("#{error_msg} end with '#{value}' but found '#{actual}'") unless actual.end_with?(value)
360
- when :contains
361
- ExceptionQueue.enqueue_exception("#{error_msg} contain '#{value}' but found '#{actual}'") unless actual.include?(value)
362
- when :not_contains, :does_not_contain
363
- ExceptionQueue.enqueue_exception("#{error_msg} not contain '#{value}' but found '#{actual}'") if actual.include?(value)
364
- when :not_equal
365
- ExceptionQueue.enqueue_exception("#{error_msg} not equal '#{value}' but found '#{actual}'") if actual == value
366
- when :like, :is_like
367
- actual_like = actual.delete("\n")
368
- actual_like = actual_like.delete("\r")
369
- actual_like = actual_like.delete("\t")
370
- actual_like = actual_like.delete(' ')
371
- actual_like = actual_like.downcase
372
- expected = value.delete("\n")
373
- expected = expected.delete("\r")
374
- expected = expected.delete("\t")
375
- expected = expected.delete(' ')
376
- expected = expected.downcase
377
- ExceptionQueue.enqueue_exception("#{error_msg} be like '#{value}' but found '#{actual}'") unless actual_like.include?(expected)
378
- when :translate
379
- expected = I18n.t(value)
380
- ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) translated #{property} property")
381
- end
382
- end
383
- else
384
- ExceptionQueue.enqueue_assert_equal(state, actual, "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property")
385
- end
345
+ error_msg = "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property to"
346
+ ExceptionQueue.enqueue_comparison(state, actual, error_msg)
386
347
  end
387
348
  end
388
349
  rescue ObjectNotFoundError => e
@@ -404,6 +365,7 @@ module TestCentricity
404
365
  when :checkbox
405
366
  data_field.set_checkbox_state(data_param.to_bool)
406
367
  when :textfield
368
+ data_field.clear
407
369
  data_field.set("#{data_param}\t")
408
370
  end
409
371
  end
File without changes
@@ -55,7 +55,11 @@ module TestCentricity
55
55
  object_not_found_exception(obj)
56
56
  if value.is_a?(Array)
57
57
  obj.send_keys(value[0])
58
- obj.send_keys(value[1])
58
+ if value[1].is_a?(Integer)
59
+ press_keycode(value[1])
60
+ else
61
+ obj.send_keys(value[1])
62
+ end
59
63
  elsif value.is_a?(String)
60
64
  obj.send_keys(value)
61
65
  end
@@ -218,14 +222,17 @@ module TestCentricity
218
222
  # Wait until the object's value equals the specified value, or until the specified wait time has expired. If the wait
219
223
  # time is nil, then the wait time will be Environ.default_max_wait_time.
220
224
  #
225
+ # @param value [String or Hash] value expected or comparison hash
221
226
  # @param seconds [Integer or Float] wait time in seconds
222
227
  # @example
223
- # card_authorized_label.wait_until_value_is(5, 'Card authorized')
228
+ # card_authorized_label.wait_until_value_is('Card authorized', 5)
229
+ # or
230
+ # total_weight_field.wait_until_value_is({ :greater_than => '250' }, 5)
224
231
  #
225
232
  def wait_until_value_is(value, seconds = nil)
226
233
  timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
227
234
  wait = Selenium::WebDriver::Wait.new(timeout: timeout)
228
- wait.until { get_value == value }
235
+ wait.until { compare(value, get_value) }
229
236
  rescue
230
237
  raise "Value of UI #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_value == value
231
238
  end
@@ -337,5 +344,28 @@ module TestCentricity
337
344
  def object_ref_message
338
345
  "object '#{@name}' (#{get_locator})"
339
346
  end
347
+
348
+ def compare(expected, actual)
349
+ if expected.is_a?(Hash)
350
+ result = false
351
+ expected.each do |key, value|
352
+ case key
353
+ when :lt, :less_than
354
+ result = actual < value
355
+ when :lt_eq, :less_than_or_equal
356
+ result = actual <= value
357
+ when :gt, :greater_than
358
+ result = actual > value
359
+ when :gt_eq, :greater_than_or_equal
360
+ result = actual >= value
361
+ when :not_equal
362
+ result = actual != value
363
+ end
364
+ end
365
+ else
366
+ result = expected == actual
367
+ end
368
+ result
369
+ end
340
370
  end
341
371
  end
@@ -2,7 +2,7 @@ module TestCentricity
2
2
  class AppCheckBox < AppUIElement
3
3
  def initialize(name, parent, locator, context)
4
4
  super
5
- @type = :checkbox
5
+ @type = :checkbox
6
6
  end
7
7
 
8
8
  def checked?
@@ -11,16 +11,32 @@ module TestCentricity
11
11
  obj.attribute('checked') == 'true'
12
12
  end
13
13
 
14
+ # Set the check state of a checkbox object.
15
+ #
16
+ # @example
17
+ # remember_me_checkbox.check
18
+ #
14
19
  def check
15
- obj = element
16
- object_not_found_exception(obj)
17
- obj.click unless obj.attribute('checked') == 'true'
20
+ set_checkbox_state(true)
18
21
  end
19
22
 
23
+ # Uncheck a checkbox object.
24
+ #
25
+ # @example
26
+ # remember_me_checkbox.uncheck
27
+ #
20
28
  def uncheck
29
+ set_checkbox_state(false)
30
+ end
31
+
32
+ def set_checkbox_state(state)
21
33
  obj = element
22
34
  object_not_found_exception(obj)
23
- obj.click if obj.attribute('checked') == 'true'
35
+ if state
36
+ obj.click unless obj.attribute('checked') == 'true'
37
+ else
38
+ obj.click if obj.attribute('checked') == 'true'
39
+ end
24
40
  end
25
41
  end
26
42
  end
File without changes
@@ -24,10 +24,20 @@ module TestCentricity
24
24
 
25
25
  end
26
26
 
27
+ # Wait until the list's item_count equals the specified value, or until the specified wait time has expired. If the wait
28
+ # time is nil, then the wait time will be Environ.default_max_wait_time.
29
+ #
30
+ # @param value [Integer or Hash] value expected or comparison hash
31
+ # @param seconds [Integer or Float] wait time in seconds
32
+ # @example
33
+ # search_results_list.wait_until_item_count_is(10, 15)
34
+ # or
35
+ # search_results_list.wait_until_item_count_is({ :greater_than_or_equal => 1 }, 5)
36
+ #
27
37
  def wait_until_item_count_is(value, seconds = nil)
28
38
  timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
29
39
  wait = Selenium::WebDriver::Wait.new(timeout: timeout)
30
- wait.until { get_item_count == value }
40
+ wait.until { compare(value, get_item_count) }
31
41
  rescue
32
42
  raise "Value of List #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_item_count == value
33
43
  end
File without changes
@@ -28,6 +28,50 @@ module TestCentricity
28
28
  @error_queue = nil
29
29
  end
30
30
 
31
+ def self.enqueue_comparison(state, actual, error_msg)
32
+ if state.is_a?(Hash) && state.length == 1
33
+ state.each do |key, value|
34
+ case key
35
+ when :lt, :less_than
36
+ enqueue_exception("#{error_msg} be less than #{value} but found '#{actual}'") unless actual < value
37
+ when :lt_eq, :less_than_or_equal
38
+ enqueue_exception("#{error_msg} be less than or equal to #{value} but found '#{actual}'") unless actual <= value
39
+ when :gt, :greater_than
40
+ enqueue_exception("#{error_msg} be greater than #{value} but found '#{actual}'") unless actual > value
41
+ when :gt_eq, :greater_than_or_equal
42
+ enqueue_exception("#{error_msg} be greater than or equal to #{value} but found '#{actual}'") unless actual >= value
43
+ when :starts_with
44
+ enqueue_exception("#{error_msg} start with '#{value}' but found '#{actual}'") unless actual.start_with?(value)
45
+ when :ends_with
46
+ enqueue_exception("#{error_msg} end with '#{value}' but found '#{actual}'") unless actual.end_with?(value)
47
+ when :contains
48
+ enqueue_exception("#{error_msg} contain '#{value}' but found '#{actual}'") unless actual.include?(value)
49
+ when :not_contains, :does_not_contain
50
+ enqueue_exception("#{error_msg} not contain '#{value}' but found '#{actual}'") if actual.include?(value)
51
+ when :not_equal
52
+ enqueue_exception("#{error_msg} not equal '#{value}' but found '#{actual}'") if actual == value
53
+ when :like, :is_like
54
+ actual_like = actual.delete("\n")
55
+ actual_like = actual_like.delete("\r")
56
+ actual_like = actual_like.delete("\t")
57
+ actual_like = actual_like.delete(' ')
58
+ actual_like = actual_like.downcase
59
+ expected = value.delete("\n")
60
+ expected = expected.delete("\r")
61
+ expected = expected.delete("\t")
62
+ expected = expected.delete(' ')
63
+ expected = expected.downcase
64
+ enqueue_exception("#{error_msg} be like '#{value}' but found '#{actual}'") unless actual_like.include?(expected)
65
+ when :translate
66
+ expected = I18n.t(value)
67
+ enqueue_assert_equal(expected, actual, error_msg)
68
+ end
69
+ end
70
+ else
71
+ enqueue_assert_equal(state, actual, error_msg)
72
+ end
73
+ end
74
+
31
75
  private
32
76
 
33
77
  def self.enqueue(message)
@@ -1,3 +1,3 @@
1
1
  module TestCentricity
2
- VERSION = '2.3.16.1'
2
+ VERSION = '2.3.17'
3
3
  end
@@ -595,49 +595,8 @@ module TestCentricity
595
595
  end
596
596
  end
597
597
  end
598
-
599
- if state.is_a?(Hash) && state.length == 1
600
- error_msg = "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property to"
601
- state.each do |key, value|
602
- case key
603
- when :lt, :less_than
604
- ExceptionQueue.enqueue_exception("#{error_msg} be less than #{value} but found '#{actual}'") unless actual < value
605
- when :lt_eq, :less_than_or_equal
606
- ExceptionQueue.enqueue_exception("#{error_msg} be less than or equal to #{value} but found '#{actual}'") unless actual <= value
607
- when :gt, :greater_than
608
- ExceptionQueue.enqueue_exception("#{error_msg} be greater than #{value} but found '#{actual}'") unless actual > value
609
- when :gt_eq, :greater_than_or_equal
610
- ExceptionQueue.enqueue_exception("#{error_msg} be greater than or equal to #{value} but found '#{actual}'") unless actual >= value
611
- when :starts_with
612
- ExceptionQueue.enqueue_exception("#{error_msg} start with '#{value}' but found '#{actual}'") unless actual.start_with?(value)
613
- when :ends_with
614
- ExceptionQueue.enqueue_exception("#{error_msg} end with '#{value}' but found '#{actual}'") unless actual.end_with?(value)
615
- when :contains
616
- ExceptionQueue.enqueue_exception("#{error_msg} contain '#{value}' but found '#{actual}'") unless actual.include?(value)
617
- when :not_contains, :does_not_contain
618
- ExceptionQueue.enqueue_exception("#{error_msg} not contain '#{value}' but found '#{actual}'") if actual.include?(value)
619
- when :not_equal
620
- ExceptionQueue.enqueue_exception("#{error_msg} not equal '#{value}' but found '#{actual}'") if actual == value
621
- when :like, :is_like
622
- actual_like = actual.delete("\n")
623
- actual_like = actual_like.delete("\r")
624
- actual_like = actual_like.delete("\t")
625
- actual_like = actual_like.delete(' ')
626
- actual_like = actual_like.downcase
627
- expected = value.delete("\n")
628
- expected = expected.delete("\r")
629
- expected = expected.delete("\t")
630
- expected = expected.delete(' ')
631
- expected = expected.downcase
632
- ExceptionQueue.enqueue_exception("#{error_msg} be like '#{value}' but found '#{actual}'") unless actual_like.include?(expected)
633
- when :translate
634
- expected = I18n.t(value)
635
- ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) translated #{property} property")
636
- end
637
- end
638
- else
639
- ExceptionQueue.enqueue_assert_equal(state, actual, "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property")
640
- end
598
+ error_msg = "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property to"
599
+ ExceptionQueue.enqueue_comparison(state, actual, error_msg)
641
600
  end
642
601
  end
643
602
  rescue ObjectNotFoundError => e
@@ -787,49 +787,8 @@ module TestCentricity
787
787
  end
788
788
  end
789
789
  end
790
-
791
- if state.is_a?(Hash) && state.length == 1
792
- error_msg = "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property to"
793
- state.each do |key, value|
794
- case key
795
- when :lt, :less_than
796
- ExceptionQueue.enqueue_exception("#{error_msg} be less than #{value} but found '#{actual}'") unless actual < value
797
- when :lt_eq, :less_than_or_equal
798
- ExceptionQueue.enqueue_exception("#{error_msg} be less than or equal to #{value} but found '#{actual}'") unless actual <= value
799
- when :gt, :greater_than
800
- ExceptionQueue.enqueue_exception("#{error_msg} be greater than #{value} but found '#{actual}'") unless actual > value
801
- when :gt_eq, :greater_than_or_equal
802
- ExceptionQueue.enqueue_exception("#{error_msg} be greater than or equal to #{value} but found '#{actual}'") unless actual >= value
803
- when :starts_with
804
- ExceptionQueue.enqueue_exception("#{error_msg} start with '#{value}' but found '#{actual}'") unless actual.start_with?(value)
805
- when :ends_with
806
- ExceptionQueue.enqueue_exception("#{error_msg} end with '#{value}' but found '#{actual}'") unless actual.end_with?(value)
807
- when :contains
808
- ExceptionQueue.enqueue_exception("#{error_msg} contain '#{value}' but found '#{actual}'") unless actual.include?(value)
809
- when :not_contains, :does_not_contain
810
- ExceptionQueue.enqueue_exception("#{error_msg} not contain '#{value}' but found '#{actual}'") if actual.include?(value)
811
- when :not_equal
812
- ExceptionQueue.enqueue_exception("#{error_msg} not equal '#{value}' but found '#{actual}'") if actual == value
813
- when :like, :is_like
814
- actual_like = actual.delete("\n")
815
- actual_like = actual_like.delete("\r")
816
- actual_like = actual_like.delete("\t")
817
- actual_like = actual_like.delete(' ')
818
- actual_like = actual_like.downcase
819
- expected = value.delete("\n")
820
- expected = expected.delete("\r")
821
- expected = expected.delete("\t")
822
- expected = expected.delete(' ')
823
- expected = expected.downcase
824
- ExceptionQueue.enqueue_exception("#{error_msg} be like '#{value}' but found '#{actual}'") unless actual_like.include?(expected)
825
- when :translate
826
- expected = I18n.t(value)
827
- ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) translated #{property} property")
828
- end
829
- end
830
- else
831
- ExceptionQueue.enqueue_assert_equal(state, actual, "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property")
832
- end
790
+ error_msg = "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property to"
791
+ ExceptionQueue.enqueue_comparison(state, actual, error_msg)
833
792
  end
834
793
  end
835
794
  rescue ObjectNotFoundError => e
@@ -70,10 +70,20 @@ module TestCentricity
70
70
  end
71
71
  end
72
72
 
73
+ # Wait until the list's item_count equals the specified value, or until the specified wait time has expired. If the wait
74
+ # time is nil, then the wait time will be Capybara.default_max_wait_time.
75
+ #
76
+ # @param value [Integer or Hash] value expected or comparison hash
77
+ # @param seconds [Integer or Float] wait time in seconds
78
+ # @example
79
+ # search_results_list.wait_until_item_count_is(10, 15)
80
+ # or
81
+ # search_results_list.wait_until_item_count_is({ :greater_than_or_equal => 1 }, 5)
82
+ #
73
83
  def wait_until_item_count_is(value, seconds = nil)
74
84
  timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
75
85
  wait = Selenium::WebDriver::Wait.new(timeout: timeout)
76
- wait.until { get_item_count == value }
86
+ wait.until { compare(value, get_item_count) }
77
87
  rescue
78
88
  raise "Value of List #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_item_count == value
79
89
  end
@@ -301,14 +301,17 @@ module TestCentricity
301
301
  # Wait until the object's value equals the specified value, or until the specified wait time has expired. If the wait
302
302
  # time is nil, then the wait time will be Capybara.default_max_wait_time.
303
303
  #
304
+ # @param value [String or Hash] value expected or comparison hash
304
305
  # @param seconds [Integer or Float] wait time in seconds
305
306
  # @example
306
- # card_authorized_label.wait_until_value_is(5, 'Card authorized')
307
+ # card_authorized_label.wait_until_value_is('Card authorized', 5)
308
+ # or
309
+ # total_weight_field.wait_until_value_is({ :greater_than => '250' }, 5)
307
310
  #
308
311
  def wait_until_value_is(value, seconds = nil)
309
312
  timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
310
313
  wait = Selenium::WebDriver::Wait.new(timeout: timeout)
311
- wait.until { get_value == value }
314
+ wait.until { compare(value, get_value) }
312
315
  rescue
313
316
  raise "Value of UI #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_value == value
314
317
  end
@@ -502,5 +505,28 @@ module TestCentricity
502
505
  def object_ref_message
503
506
  "object '#{get_name}' (#{get_locator})"
504
507
  end
508
+
509
+ def compare(expected, actual)
510
+ if expected.is_a?(Hash)
511
+ result = false
512
+ expected.each do |key, value|
513
+ case key
514
+ when :lt, :less_than
515
+ result = actual < value
516
+ when :lt_eq, :less_than_or_equal
517
+ result = actual <= value
518
+ when :gt, :greater_than
519
+ result = actual > value
520
+ when :gt_eq, :greater_than_or_equal
521
+ result = actual >= value
522
+ when :not_equal
523
+ result = actual != value
524
+ end
525
+ end
526
+ else
527
+ result = expected == actual
528
+ end
529
+ result
530
+ end
505
531
  end
506
532
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testcentricity
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.16.1
4
+ version: 2.3.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - A.J. Mrozinski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-04 00:00:00.000000000 Z
11
+ date: 2018-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler