testcentricity_web 4.0.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,29 @@
1
1
  module TestCentricity
2
2
  class CheckBox < UIElement
3
3
  attr_accessor :proxy
4
+ attr_accessor :label
4
5
 
5
- def initialize(name, parent, locator, context, proxy = nil)
6
- @name = name
7
- @parent = parent
8
- @locator = locator
9
- @context = context
10
- @alt_locator = nil
11
- @proxy = proxy
12
- @type = :checkbox
13
- set_locator_type
6
+ def initialize(name, parent, locator, context)
7
+ super
8
+ @type = :checkbox
9
+ check_spec = {
10
+ proxy: nil,
11
+ label: nil
12
+ }
13
+ define_custom_elements(check_spec)
14
+ end
15
+
16
+ def define_custom_elements(element_spec)
17
+ element_spec.each do |element, value|
18
+ case element
19
+ when :proxy
20
+ @proxy = value
21
+ when :label
22
+ @label = value
23
+ else
24
+ raise "#{element} is not a recognized checkbox element"
25
+ end
26
+ end
14
27
  end
15
28
 
16
29
  # Does checkbox object exists?
@@ -54,7 +67,7 @@ module TestCentricity
54
67
  # remember_me_checkbox.visible?
55
68
  #
56
69
  def visible?
57
- @proxy.nil? ? super : @proxy.visible?
70
+ @proxy.nil? ? super : page.find(:css, @proxy).visible?
58
71
  end
59
72
 
60
73
  # Is checkbox disabled (not enabled)?
@@ -77,9 +90,17 @@ module TestCentricity
77
90
  # remember_me_checkbox.get_value
78
91
  #
79
92
  def get_value
80
- @proxy.nil? ? super : @proxy.get_value
93
+ if @label.nil?
94
+ @proxy.nil? ? super : page.find(:css, @proxy).text
95
+ else
96
+ page.find(:css, @label).text
97
+ end
81
98
  end
82
99
 
100
+ alias get_caption get_value
101
+ alias caption get_value
102
+ alias value get_value
103
+
83
104
  # Set the check state of a checkbox object.
84
105
  #
85
106
  # @param state [Boolean] true = checked / false = unchecked
@@ -98,7 +119,7 @@ module TestCentricity
98
119
  obj.set(state)
99
120
  end
100
121
  else
101
- @proxy.click unless state == obj.checked?
122
+ page.find(:css, @proxy).click unless state == obj.checked?
102
123
  end
103
124
  end
104
125
 
@@ -126,25 +147,5 @@ module TestCentricity
126
147
  ExceptionQueue.enqueue_assert_equal(state, actual, "Expected checkbox #{object_ref_message}") :
127
148
  assert_equal(state, actual, "Expected checkbox #{object_ref_message} to be #{state} but found #{actual} instead")
128
149
  end
129
-
130
- # Highlight a checkbox with a 3 pixel wide, red dashed border for the specified wait time.
131
- # If wait time is zero, then the highlight will remain until the page is refreshed
132
- #
133
- # @param duration [Integer or Float] wait time in seconds
134
- # @example
135
- # remember_me_checkbox.highlight(3)
136
- #
137
- def highlight(duration = 1)
138
- @proxy.nil? ? super : @proxy.highlight(duration)
139
- end
140
-
141
- # Restore a highlighted checkbox's original style
142
- #
143
- # @example
144
- # remember_me_checkbox.unhighlight
145
- #
146
- def unhighlight
147
- @proxy.nil? ? super : @proxy.unhighlight
148
- end
149
150
  end
150
151
  end
@@ -1,16 +1,29 @@
1
1
  module TestCentricity
2
2
  class Radio < UIElement
3
3
  attr_accessor :proxy
4
+ attr_accessor :label
4
5
 
5
- def initialize(name, parent, locator, context, proxy = nil)
6
- @name = name
7
- @parent = parent
8
- @locator = locator
9
- @context = context
10
- @alt_locator = nil
11
- @proxy = proxy
12
- @type = :radio
13
- set_locator_type
6
+ def initialize(name, parent, locator, context)
7
+ super
8
+ @type = :radio
9
+ radio_spec = {
10
+ proxy: nil,
11
+ label: nil
12
+ }
13
+ define_custom_elements(radio_spec)
14
+ end
15
+
16
+ def define_custom_elements(element_spec)
17
+ element_spec.each do |element, value|
18
+ case element
19
+ when :proxy
20
+ @proxy = value
21
+ when :label
22
+ @label = value
23
+ else
24
+ raise "#{element} is not a recognized radio element"
25
+ end
26
+ end
14
27
  end
15
28
 
16
29
  # Does radio button object exists?
@@ -43,7 +56,7 @@ module TestCentricity
43
56
  # accept_terms_radio.visible?
44
57
  #
45
58
  def visible?
46
- @proxy.nil? ? super : @proxy.visible?
59
+ @proxy.nil? ? super : page.find(:css, @proxy).visible?
47
60
  end
48
61
 
49
62
  # Is radio button disabled (not enabled)?
@@ -66,9 +79,17 @@ module TestCentricity
66
79
  # accept_terms_radio.get_value
67
80
  #
68
81
  def get_value
69
- @proxy.nil? ? super : @proxy.get_value
82
+ if @label.nil?
83
+ @proxy.nil? ? super : page.find(:css, @proxy).text
84
+ else
85
+ page.find(:css, @label).text
86
+ end
70
87
  end
71
88
 
89
+ alias get_caption get_value
90
+ alias caption get_value
91
+ alias value get_value
92
+
72
93
  # Set the select state of a radio button object.
73
94
  #
74
95
  # @param state [Boolean] true = selected / false = unselected
@@ -82,7 +103,7 @@ module TestCentricity
82
103
  if @proxy.nil?
83
104
  obj.set(state)
84
105
  else
85
- @proxy.click unless state == obj.checked?
106
+ page.find(:css, @proxy).click unless state == obj.checked?
86
107
  end
87
108
  end
88
109
 
@@ -103,25 +124,5 @@ module TestCentricity
103
124
  def unselect
104
125
  set_selected_state(state = false)
105
126
  end
106
-
107
- # Highlight a radio button with a 3 pixel wide, red dashed border for the specified wait time.
108
- # If wait time is zero, then the highlight will remain until the page is refreshed
109
- #
110
- # @param duration [Integer or Float] wait time in seconds
111
- # @example
112
- # accept_terms_radio.highlight(3)
113
- #
114
- def highlight(duration = 1)
115
- @proxy.nil? ? super : @proxy.highlight(duration)
116
- end
117
-
118
- # Restore a highlighted radio button's original style
119
- #
120
- # @example
121
- # accept_terms_radio.unhighlight
122
- #
123
- def unhighlight
124
- @proxy.nil? ? super : @proxy.unhighlight
125
- end
126
127
  end
127
128
  end
@@ -7,7 +7,6 @@ module TestCentricity
7
7
  attr_accessor :options_list
8
8
  attr_accessor :group_item
9
9
  attr_accessor :group_heading
10
- attr_accessor :base_object
11
10
 
12
11
  def initialize(name, parent, locator, context)
13
12
  super
@@ -286,18 +285,5 @@ module TestCentricity
286
285
  trigger.click
287
286
  end
288
287
  end
289
-
290
- def find_component(component, component_name)
291
- begin
292
- element = @base_object.find(:css, component, minimum: 0, wait: 1)
293
- rescue
294
- begin
295
- element = page.find(:css, component, minimum: 0, wait: 5)
296
- rescue
297
- raise "List #{component_name} (#{component}) for selectlist named '#{@name}' (#{locator}) not found"
298
- end
299
- end
300
- element
301
- end
302
288
  end
303
289
  end
@@ -44,6 +44,7 @@ module TestCentricity
44
44
 
45
45
  attr_reader :parent, :locator, :context, :type, :name
46
46
  attr_accessor :alt_locator, :locator_type, :original_style
47
+ attr_accessor :base_object
47
48
 
48
49
  XPATH_SELECTORS = ['//', '[@', '[contains(']
49
50
  CSS_SELECTORS = ['#', ':nth-child(', ':first-child', ':last-child', ':nth-of-type(', ':first-of-type', ':last-of-type', '^=', '$=', '*=', ':contains(']
@@ -196,7 +197,7 @@ module TestCentricity
196
197
  #
197
198
  def exists?(visible = true)
198
199
  obj, = find_object(visible)
199
- obj != nil
200
+ !obj.nil?
200
201
  end
201
202
 
202
203
  # Is UI object visible?
@@ -516,6 +517,8 @@ module TestCentricity
516
517
  end
517
518
 
518
519
  alias get_caption get_value
520
+ alias caption get_value
521
+ alias value get_value
519
522
 
520
523
  def verify_value(expected, enqueue = false)
521
524
  actual = get_value
@@ -1064,5 +1067,18 @@ module TestCentricity
1064
1067
  expected == actual
1065
1068
  end
1066
1069
  end
1070
+
1071
+ def find_component(component, component_name)
1072
+ begin
1073
+ element = @base_object.find(:css, component, minimum: 0, wait: 1)
1074
+ rescue
1075
+ begin
1076
+ element = page.find(:css, component, minimum: 0, wait: 5)
1077
+ rescue
1078
+ raise "Component #{component_name} (#{component}) for #{@type} named '#{@name}' (#{locator}) not found"
1079
+ end
1080
+ end
1081
+ element
1082
+ end
1067
1083
  end
1068
1084
  end
@@ -1,4 +1,3 @@
1
- require 'capybara/cucumber'
2
1
  require 'test/unit'
3
2
  require 'appium_lib'
4
3
 
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = 'testcentricity_web'
8
8
  spec.version = TestCentricityWeb::VERSION
9
9
  spec.platform = Gem::Platform::RUBY
10
- spec.required_ruby_version = '>= 2.3.0'
10
+ spec.required_ruby_version = '>= 2.7.5'
11
11
  spec.authors = ['A.J. Mrozinski']
12
12
  spec.email = ['testcentricity@gmail.com']
13
13
  spec.summary = 'A Page Object and Data Object Model Framework for desktop and mobile web testing'
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_runtime_dependency 'appium_lib'
35
35
  spec.add_runtime_dependency 'browserstack-local'
36
36
  spec.add_runtime_dependency 'capybara', '>= 3.1', '< 4'
37
- spec.add_runtime_dependency 'childprocess', '~> 0.5'
37
+ spec.add_runtime_dependency 'childprocess'
38
38
  spec.add_runtime_dependency 'chronic', '0.10.2'
39
39
  spec.add_runtime_dependency 'faker'
40
40
  spec.add_runtime_dependency 'i18n'
@@ -42,6 +42,6 @@ Gem::Specification.new do |spec|
42
42
  spec.add_runtime_dependency 'selenium-webdriver'
43
43
  spec.add_runtime_dependency 'spreadsheet', '1.1.7'
44
44
  spec.add_runtime_dependency 'test-unit'
45
- spec.add_runtime_dependency 'webdrivers', '~> 4.0'
45
+ spec.add_runtime_dependency 'webdrivers', '~> 5.0'
46
46
  spec.add_runtime_dependency 'virtus'
47
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testcentricity_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - A.J. Mrozinski
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-20 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -90,16 +90,16 @@ dependencies:
90
90
  name: childprocess
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - "~>"
93
+ - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: '0.5'
95
+ version: '0'
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "~>"
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: '0.5'
102
+ version: '0'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: chronic
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -204,14 +204,14 @@ dependencies:
204
204
  requirements:
205
205
  - - "~>"
206
206
  - !ruby/object:Gem::Version
207
- version: '4.0'
207
+ version: '5.0'
208
208
  type: :runtime
209
209
  prerelease: false
210
210
  version_requirements: !ruby/object:Gem::Requirement
211
211
  requirements:
212
212
  - - "~>"
213
213
  - !ruby/object:Gem::Version
214
- version: '4.0'
214
+ version: '5.0'
215
215
  - !ruby/object:Gem::Dependency
216
216
  name: virtus
217
217
  requirement: !ruby/object:Gem::Requirement
@@ -253,7 +253,6 @@ files:
253
253
  - CHANGELOG.md
254
254
  - CODE_OF_CONDUCT.md
255
255
  - Gemfile
256
- - Gemfile.lock
257
256
  - LICENSE.md
258
257
  - README.md
259
258
  - Rakefile
@@ -295,7 +294,7 @@ homepage: ''
295
294
  licenses:
296
295
  - BSD-3-Clause
297
296
  metadata: {}
298
- post_install_message:
297
+ post_install_message:
299
298
  rdoc_options: []
300
299
  require_paths:
301
300
  - lib
@@ -303,7 +302,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
303
302
  requirements:
304
303
  - - ">="
305
304
  - !ruby/object:Gem::Version
306
- version: 2.3.0
305
+ version: 2.7.5
307
306
  required_rubygems_version: !ruby/object:Gem::Requirement
308
307
  requirements:
309
308
  - - ">="
@@ -311,9 +310,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
311
310
  version: '0'
312
311
  requirements:
313
312
  - Capybara, Selenium-WebDriver
314
- rubyforge_project:
315
- rubygems_version: 2.7.9
316
- signing_key:
313
+ rubygems_version: 3.1.6
314
+ signing_key:
317
315
  specification_version: 4
318
316
  summary: A Page Object and Data Object Model Framework for desktop and mobile web
319
317
  testing
data/Gemfile.lock DELETED
@@ -1,112 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- testcentricity_web (4.0.1)
5
- appium_lib
6
- browserstack-local
7
- capybara (>= 3.1, < 4)
8
- childprocess (~> 0.5)
9
- chronic (= 0.10.2)
10
- faker
11
- i18n
12
- os (~> 1.0)
13
- selenium-webdriver
14
- spreadsheet (= 1.1.7)
15
- test-unit
16
- virtus
17
- webdrivers (~> 4.0)
18
-
19
- GEM
20
- remote: https://rubygems.org/
21
- specs:
22
- addressable (2.7.0)
23
- public_suffix (>= 2.0.2, < 5.0)
24
- appium_lib (11.2.0)
25
- appium_lib_core (~> 4.1)
26
- nokogiri (~> 1.8, >= 1.8.1)
27
- tomlrb (~> 1.1)
28
- appium_lib_core (4.5.0)
29
- faye-websocket (~> 0.11.0)
30
- selenium-webdriver (~> 3.14, >= 3.14.1)
31
- axiom-types (0.1.1)
32
- descendants_tracker (~> 0.0.4)
33
- ice_nine (~> 0.11.0)
34
- thread_safe (~> 0.3, >= 0.3.1)
35
- browserstack-local (1.3.0)
36
- capybara (3.35.3)
37
- addressable
38
- mini_mime (>= 0.1.3)
39
- nokogiri (~> 1.8)
40
- rack (>= 1.6.0)
41
- rack-test (>= 0.6.3)
42
- regexp_parser (>= 1.5, < 3.0)
43
- xpath (~> 3.2)
44
- childprocess (0.9.0)
45
- ffi (~> 1.0, >= 1.0.11)
46
- chronic (0.10.2)
47
- coercible (1.0.0)
48
- descendants_tracker (~> 0.0.1)
49
- concurrent-ruby (1.1.8)
50
- descendants_tracker (0.0.4)
51
- thread_safe (~> 0.3, >= 0.3.1)
52
- equalizer (0.0.11)
53
- eventmachine (1.2.7)
54
- faker (2.17.0)
55
- i18n (>= 1.6, < 2)
56
- faye-websocket (0.11.0)
57
- eventmachine (>= 0.12.0)
58
- websocket-driver (>= 0.5.1)
59
- ffi (1.15.0)
60
- i18n (1.8.10)
61
- concurrent-ruby (~> 1.0)
62
- ice_nine (0.11.2)
63
- mini_mime (1.1.0)
64
- nokogiri (1.11.3-x86_64-darwin)
65
- racc (~> 1.4)
66
- os (1.1.1)
67
- power_assert (2.0.0)
68
- public_suffix (4.0.6)
69
- racc (1.5.2)
70
- rack (2.2.3)
71
- rack-test (1.1.0)
72
- rack (>= 1.0, < 3)
73
- rake (13.0.1)
74
- redcarpet (3.5.0)
75
- regexp_parser (2.1.1)
76
- ruby-ole (1.2.12.2)
77
- rubyzip (2.3.0)
78
- selenium-webdriver (3.142.7)
79
- childprocess (>= 0.5, < 4.0)
80
- rubyzip (>= 1.2.2)
81
- spreadsheet (1.1.7)
82
- ruby-ole (>= 1.0)
83
- test-unit (3.4.1)
84
- power_assert
85
- thread_safe (0.3.6)
86
- tomlrb (1.3.0)
87
- virtus (1.0.5)
88
- axiom-types (~> 0.1)
89
- coercible (~> 1.0)
90
- descendants_tracker (~> 0.0, >= 0.0.3)
91
- equalizer (~> 0.0, >= 0.0.9)
92
- webdrivers (4.6.0)
93
- nokogiri (~> 1.6)
94
- rubyzip (>= 1.3.0)
95
- selenium-webdriver (>= 3.0, < 4.0)
96
- websocket-driver (0.7.3)
97
- websocket-extensions (>= 0.1.0)
98
- websocket-extensions (0.1.5)
99
- xpath (3.2.0)
100
- nokogiri (~> 1.8)
101
-
102
- PLATFORMS
103
- ruby
104
-
105
- DEPENDENCIES
106
- bundler
107
- rake
108
- redcarpet
109
- testcentricity_web!
110
-
111
- BUNDLED WITH
112
- 2.1.4