testcentricity 2.3.17 → 2.3.18

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: 254dae3895ab2f916930ce27ec170ae272e8aa53
4
- data.tar.gz: 1c34b8a232896f140423225c73e97f9be2a1603a
3
+ metadata.gz: 7457dc7a397379758049f8cded2a9f3f125975c5
4
+ data.tar.gz: bf0f1a84f5bbc6dfedef74d78af5213ae0d1bf40
5
5
  SHA512:
6
- metadata.gz: 7a0e9e601a675a2c3118c8bd4840bf7c1957e415203e5eca4a57d623a8e74671d7a7820f6280ac4e2d72fec999ce4e523fbc3bb9dc61faaedbd26587a3bc2b55
7
- data.tar.gz: 4bb9432870f15132fca627333747c7da429b38b924252946c11531ba8764f64050547ecb3764b525e0cc74d04f63b4fd0f5dbb433d013a9560590f7a4ad0afc6
6
+ metadata.gz: bcf2dd6f67cd28f22c07a40ee0bc18099389eccb37734d2049c11c9d1fa4df87a568289af5a3ca87e55459576ba817cf53226fc1744aec29df53c40bce782f6f
7
+ data.tar.gz: 4dca911af8a4b4b239b5c0d59c4d33efd8bbf6cf1f7739c1e870e2c4df808490e94d2853a6efba3c48c072eec234e6ff228b513f50e09d3de6377afe4e0a7855
data/README.md CHANGED
@@ -28,6 +28,13 @@ hosted instances of Chrome, Firefox, Safari, and IE web browsers.
28
28
 
29
29
 
30
30
  ## What's New
31
+ ###Version 2.3.18
32
+
33
+ * Updated `SelectList.define_list_elements` method to accept value for `:list_trigger` element.
34
+ * Updated `SelectList.choose_option` to respect `:list_item` value and to click on `:list_trigger` element, if one is specified.
35
+ * Updated `PageSection` and `PageObject` UI element object declaration methods to no longer use `class_eval` pattern.
36
+ * Updated device profiles for iPhone 7 (iOS 10) with Chrome browser and iPad (iOS 10) with Chrome browser.
37
+
31
38
  ###Version 2.3.17
32
39
 
33
40
  * Added `List.wait_until_item_count_is` and `List.wait_until_item_count_changes` methods.
@@ -145,6 +152,10 @@ use the [parallel_tests gem](https://rubygems.org/gems/parallel_tests) to decrea
145
152
 
146
153
 
147
154
  ## What's Fixed
155
+ ###Version 2.3.18
156
+
157
+ * Fixed `SelectList.choose_option` to also accept `:text`, `:value`, and `:index` option hashes across all types of select list objects.
158
+
148
159
 
149
160
  ###Version 2.3.15
150
161
 
@@ -61,7 +61,7 @@
61
61
  :css_width: 375
62
62
  :css_height: 667
63
63
  :default_orientation: portrait
64
- :user_agent: "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) CriOS/64.0.3282.112 Mobile/14G60 Safari/602.1"
64
+ :user_agent: "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) CriOS/65.0.3325.152 Mobile/14G60 Safari/602.1"
65
65
  :iphone7_firefox:
66
66
  :name: "iPhone 7 - Firefox"
67
67
  :os: ios
@@ -237,7 +237,7 @@ nexus6:
237
237
  :css_width: 1024
238
238
  :css_height: 768
239
239
  :default_orientation: landscape
240
- :user_agent: "Mozilla/5.0 (iPad; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) CriOS/64.0.3282.112 Mobile/14G60 Safari/602.1"
240
+ :user_agent: "Mozilla/5.0 (iPad; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) CriOS/65.0.3325.152 Mobile/14G60 Safari/602.1"
241
241
  :ipad_firefox:
242
242
  :name: "iPad - Firefox"
243
243
  :os: ios
@@ -15,8 +15,17 @@ module TestCentricity
15
15
  define_method(trait_name.to_s, &block)
16
16
  end
17
17
 
18
+ # def self.element(element_name, locator)
19
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppUIElement.new("#{element_name}", self, #{locator}, :page);end))
20
+ # end
21
+
18
22
  def self.element(element_name, locator)
19
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppUIElement.new("#{element_name}", self, #{locator}, :page);end))
23
+ define_method(element_name) do
24
+ ivar_name = "@#{element_name}"
25
+ ivar = instance_variable_get(ivar_name)
26
+ return ivar if ivar
27
+ instance_variable_set(ivar_name, TestCentricity::AppUIElement.new(element_name, self, locator, :page))
28
+ end
20
29
  end
21
30
 
22
31
  def self.elements(element_hash)
@@ -25,8 +34,17 @@ module TestCentricity
25
34
  end
26
35
  end
27
36
 
37
+ # def self.button(element_name, locator)
38
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppButton.new("#{element_name}", self, #{locator}, :page);end))
39
+ # end
40
+
28
41
  def self.button(element_name, locator)
29
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppButton.new("#{element_name}", self, #{locator}, :page);end))
42
+ define_method(element_name) do
43
+ ivar_name = "@#{element_name}"
44
+ ivar = instance_variable_get(ivar_name)
45
+ return ivar if ivar
46
+ instance_variable_set(ivar_name, TestCentricity::AppButton.new(element_name, self, locator, :page))
47
+ end
30
48
  end
31
49
 
32
50
  def self.buttons(element_hash)
@@ -35,8 +53,17 @@ module TestCentricity
35
53
  end
36
54
  end
37
55
 
56
+ # def self.textfield(element_name, locator)
57
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppTextField.new("#{element_name}", self, #{locator}, :page);end))
58
+ # end
59
+
38
60
  def self.textfield(element_name, locator)
39
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppTextField.new("#{element_name}", self, #{locator}, :page);end))
61
+ define_method(element_name) do
62
+ ivar_name = "@#{element_name}"
63
+ ivar = instance_variable_get(ivar_name)
64
+ return ivar if ivar
65
+ instance_variable_set(ivar_name, TestCentricity::AppTextField.new(element_name, self, locator, :page))
66
+ end
40
67
  end
41
68
 
42
69
  def self.textfields(element_hash)
@@ -45,8 +72,17 @@ module TestCentricity
45
72
  end
46
73
  end
47
74
 
75
+ # def self.switch(element_name, locator)
76
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSwitch.new("#{element_name}", self, #{locator}, :page);end))
77
+ # end
78
+
48
79
  def self.switch(element_name, locator)
49
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSwitch.new("#{element_name}", self, #{locator}, :page);end))
80
+ define_method(element_name) do
81
+ ivar_name = "@#{element_name}"
82
+ ivar = instance_variable_get(ivar_name)
83
+ return ivar if ivar
84
+ instance_variable_set(ivar_name, TestCentricity::AppSwitch.new(element_name, self, locator, :page))
85
+ end
50
86
  end
51
87
 
52
88
  def self.switches(element_hash)
@@ -55,8 +91,17 @@ module TestCentricity
55
91
  end
56
92
  end
57
93
 
94
+ # def self.checkbox(element_name, locator)
95
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppCheckBox.new("#{element_name}", self, #{locator}, :page);end))
96
+ # end
97
+
58
98
  def self.checkbox(element_name, locator)
59
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppCheckBox.new("#{element_name}", self, #{locator}, :page);end))
99
+ define_method(element_name) do
100
+ ivar_name = "@#{element_name}"
101
+ ivar = instance_variable_get(ivar_name)
102
+ return ivar if ivar
103
+ instance_variable_set(ivar_name, TestCentricity::AppCheckBox.new(element_name, self, locator, :page))
104
+ end
60
105
  end
61
106
 
62
107
  def self.checkboxes(element_hash)
@@ -65,8 +110,17 @@ module TestCentricity
65
110
  end
66
111
  end
67
112
 
113
+ # def self.label(element_name, locator)
114
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppLabel.new("#{element_name}", self, #{locator}, :page);end))
115
+ # end
116
+
68
117
  def self.label(element_name, locator)
69
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppLabel.new("#{element_name}", self, #{locator}, :page);end))
118
+ define_method(element_name) do
119
+ ivar_name = "@#{element_name}"
120
+ ivar = instance_variable_get(ivar_name)
121
+ return ivar if ivar
122
+ instance_variable_set(ivar_name, TestCentricity::AppLabel.new(element_name, self, locator, :page))
123
+ end
70
124
  end
71
125
 
72
126
  def self.labels(element_hash)
@@ -75,8 +129,17 @@ module TestCentricity
75
129
  end
76
130
  end
77
131
 
132
+ # def self.list(element_name, locator)
133
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppList.new("#{element_name}", self, #{locator}, :page);end))
134
+ # end
135
+
78
136
  def self.list(element_name, locator)
79
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppList.new("#{element_name}", self, #{locator}, :page);end))
137
+ define_method(element_name) do
138
+ ivar_name = "@#{element_name}"
139
+ ivar = instance_variable_get(ivar_name)
140
+ return ivar if ivar
141
+ instance_variable_set(ivar_name, TestCentricity::AppList.new(element_name, self, locator, :page))
142
+ end
80
143
  end
81
144
 
82
145
  def self.lists(element_hash)
@@ -85,8 +148,17 @@ module TestCentricity
85
148
  end
86
149
  end
87
150
 
151
+ # def self.selectlist(element_name, locator)
152
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSelectList.new("#{element_name}", self, #{locator}, :page);end))
153
+ # end
154
+
88
155
  def self.selectlist(element_name, locator)
89
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSelectList.new("#{element_name}", self, #{locator}, :page);end))
156
+ define_method(element_name) do
157
+ ivar_name = "@#{element_name}"
158
+ ivar = instance_variable_get(ivar_name)
159
+ return ivar if ivar
160
+ instance_variable_set(ivar_name, TestCentricity::AppSelectList.new(element_name, self, locator, :page))
161
+ end
90
162
  end
91
163
 
92
164
  def self.selectlists(element_hash)
@@ -95,8 +167,17 @@ module TestCentricity
95
167
  end
96
168
  end
97
169
 
170
+ # def self.image(element_name, locator)
171
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppImage.new("#{element_name}", self, #{locator}, :page);end))
172
+ # end
173
+
98
174
  def self.image(element_name, locator)
99
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppImage.new("#{element_name}", self, #{locator}, :page);end))
175
+ define_method(element_name) do
176
+ ivar_name = "@#{element_name}"
177
+ ivar = instance_variable_get(ivar_name)
178
+ return ivar if ivar
179
+ instance_variable_set(ivar_name, TestCentricity::AppImage.new(element_name, self, locator, :page))
180
+ end
100
181
  end
101
182
 
102
183
  def self.images(element_hash)
@@ -105,8 +186,17 @@ module TestCentricity
105
186
  end
106
187
  end
107
188
 
189
+ # def self.alert(element_name, locator)
190
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppAlert.new("#{element_name}", self, #{locator}, :page);end))
191
+ # end
192
+
108
193
  def self.alert(element_name, locator)
109
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppAlert.new("#{element_name}", self, #{locator}, :page);end))
194
+ define_method(element_name) do
195
+ ivar_name = "@#{element_name}"
196
+ ivar = instance_variable_get(ivar_name)
197
+ return ivar if ivar
198
+ instance_variable_set(ivar_name, TestCentricity::AppAlert.new(element_name, self, locator, :page))
199
+ end
110
200
  end
111
201
 
112
202
  def self.section(section_name, class_name, locator = 0)
@@ -20,21 +20,25 @@ module TestCentricity
20
20
  end
21
21
 
22
22
  def get_locator
23
- @locator = section_locator if @locator.zero? && defined?(section_locator)
23
+ if @locator.zero? && defined?(section_locator)
24
+ my_locator = section_locator
25
+ else
26
+ my_locator = @locator
27
+ end
24
28
  locators = []
25
29
  if @context == :section && !@parent.nil?
26
30
  locators.push(@parent.get_locator)
27
31
  end
28
32
 
29
33
  if @parent_list.nil?
30
- locators.push(@locator)
34
+ locators.push(my_locator)
31
35
  else
32
36
  locators.push(@parent_list.get_locator)
33
37
  if @list_index.nil?
34
- locators.push(@locator)
38
+ locators.push(my_locator)
35
39
  else
36
- list_key = @locator.keys[0]
37
- list_value = "#{@locator.values[0]}[#{@list_index}]"
40
+ list_key = my_locator.keys[0]
41
+ list_value = "#{my_locator.values[0]}[#{@list_index}]"
38
42
  locators.push( { list_key => list_value } )
39
43
  end
40
44
  end
@@ -76,8 +80,17 @@ module TestCentricity
76
80
  define_method(trait_name.to_s, &block)
77
81
  end
78
82
 
83
+ # def self.element(element_name, locator)
84
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppUIElement.new("#{element_name}", self, #{locator}, :section);end))
85
+ # end
86
+
79
87
  def self.element(element_name, locator)
80
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppUIElement.new("#{element_name}", self, #{locator}, :section);end))
88
+ define_method(element_name) do
89
+ ivar_name = "@#{element_name}"
90
+ ivar = instance_variable_get(ivar_name)
91
+ return ivar if ivar
92
+ instance_variable_set(ivar_name, TestCentricity::AppUIElement.new(element_name, self, locator, :section))
93
+ end
81
94
  end
82
95
 
83
96
  def self.elements(element_hash)
@@ -86,8 +99,17 @@ module TestCentricity
86
99
  end
87
100
  end
88
101
 
102
+ # def self.button(element_name, locator)
103
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppButton.new("#{element_name}", self, #{locator}, :section);end))
104
+ # end
105
+
89
106
  def self.button(element_name, locator)
90
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppButton.new("#{element_name}", self, #{locator}, :section);end))
107
+ define_method(element_name) do
108
+ ivar_name = "@#{element_name}"
109
+ ivar = instance_variable_get(ivar_name)
110
+ return ivar if ivar
111
+ instance_variable_set(ivar_name, TestCentricity::AppButton.new(element_name, self, locator, :section))
112
+ end
91
113
  end
92
114
 
93
115
  def self.buttons(element_hash)
@@ -96,8 +118,17 @@ module TestCentricity
96
118
  end
97
119
  end
98
120
 
121
+ # def self.textfield(element_name, locator)
122
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppTextField.new("#{element_name}", self, #{locator}, :section);end))
123
+ # end
124
+
99
125
  def self.textfield(element_name, locator)
100
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppTextField.new("#{element_name}", self, #{locator}, :section);end))
126
+ define_method(element_name) do
127
+ ivar_name = "@#{element_name}"
128
+ ivar = instance_variable_get(ivar_name)
129
+ return ivar if ivar
130
+ instance_variable_set(ivar_name, TestCentricity::AppTextField.new(element_name, self, locator, :section))
131
+ end
101
132
  end
102
133
 
103
134
  def self.textfields(element_hash)
@@ -106,8 +137,17 @@ module TestCentricity
106
137
  end
107
138
  end
108
139
 
140
+ # def self.switch(element_name, locator)
141
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSwitch.new("#{element_name}", self, #{locator}, :section);end))
142
+ # end
143
+
109
144
  def self.switch(element_name, locator)
110
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSwitch.new("#{element_name}", self, #{locator}, :section);end))
145
+ define_method(element_name) do
146
+ ivar_name = "@#{element_name}"
147
+ ivar = instance_variable_get(ivar_name)
148
+ return ivar if ivar
149
+ instance_variable_set(ivar_name, TestCentricity::AppSwitch.new(element_name, self, locator, :section))
150
+ end
111
151
  end
112
152
 
113
153
  def self.switches(element_hash)
@@ -116,8 +156,17 @@ module TestCentricity
116
156
  end
117
157
  end
118
158
 
159
+ # def self.checkbox(element_name, locator)
160
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppCheckBox.new("#{element_name}", self, #{locator}, :section);end))
161
+ # end
162
+
119
163
  def self.checkbox(element_name, locator)
120
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppCheckBox.new("#{element_name}", self, #{locator}, :section);end))
164
+ define_method(element_name) do
165
+ ivar_name = "@#{element_name}"
166
+ ivar = instance_variable_get(ivar_name)
167
+ return ivar if ivar
168
+ instance_variable_set(ivar_name, TestCentricity::AppCheckBox.new(element_name, self, locator, :section))
169
+ end
121
170
  end
122
171
 
123
172
  def self.checkboxes(element_hash)
@@ -126,8 +175,17 @@ module TestCentricity
126
175
  end
127
176
  end
128
177
 
178
+ # def self.label(element_name, locator)
179
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppLabel.new("#{element_name}", self, #{locator}, :section);end))
180
+ # end
181
+
129
182
  def self.label(element_name, locator)
130
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppLabel.new("#{element_name}", self, #{locator}, :section);end))
183
+ define_method(element_name) do
184
+ ivar_name = "@#{element_name}"
185
+ ivar = instance_variable_get(ivar_name)
186
+ return ivar if ivar
187
+ instance_variable_set(ivar_name, TestCentricity::AppLabel.new(element_name, self, locator, :section))
188
+ end
131
189
  end
132
190
 
133
191
  def self.labels(element_hash)
@@ -136,8 +194,17 @@ module TestCentricity
136
194
  end
137
195
  end
138
196
 
197
+ # def self.list(element_name, locator)
198
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppList.new("#{element_name}", self, #{locator}, :section);end))
199
+ # end
200
+
139
201
  def self.list(element_name, locator)
140
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppList.new("#{element_name}", self, #{locator}, :section);end))
202
+ define_method(element_name) do
203
+ ivar_name = "@#{element_name}"
204
+ ivar = instance_variable_get(ivar_name)
205
+ return ivar if ivar
206
+ instance_variable_set(ivar_name, TestCentricity::AppList.new(element_name, self, locator, :section))
207
+ end
141
208
  end
142
209
 
143
210
  def self.lists(element_hash)
@@ -146,8 +213,17 @@ module TestCentricity
146
213
  end
147
214
  end
148
215
 
216
+ # def self.selectlist(element_name, locator)
217
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSelectList.new("#{element_name}", self, #{locator}, :section);end))
218
+ # end
219
+
149
220
  def self.selectlist(element_name, locator)
150
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSelectList.new("#{element_name}", self, #{locator}, :section);end))
221
+ define_method(element_name) do
222
+ ivar_name = "@#{element_name}"
223
+ ivar = instance_variable_get(ivar_name)
224
+ return ivar if ivar
225
+ instance_variable_set(ivar_name, TestCentricity::AppSelectList.new(element_name, self, locator, :section))
226
+ end
151
227
  end
152
228
 
153
229
  def self.selectlists(element_hash)
@@ -156,8 +232,17 @@ module TestCentricity
156
232
  end
157
233
  end
158
234
 
235
+ # def self.image(element_name, locator)
236
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppImage.new("#{element_name}", self, #{locator}, :section);end))
237
+ # end
238
+
159
239
  def self.image(element_name, locator)
160
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppImage.new("#{element_name}", self, #{locator}, :section);end))
240
+ define_method(element_name) do
241
+ ivar_name = "@#{element_name}"
242
+ ivar = instance_variable_get(ivar_name)
243
+ return ivar if ivar
244
+ instance_variable_set(ivar_name, TestCentricity::AppImage.new(element_name, self, locator, :section))
245
+ end
161
246
  end
162
247
 
163
248
  def self.images(element_hash)
@@ -166,8 +251,17 @@ module TestCentricity
166
251
  end
167
252
  end
168
253
 
254
+ # def self.alert(element_name, locator)
255
+ # class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppAlert.new("#{element_name}", self, #{locator}, :page);end))
256
+ # end
257
+
169
258
  def self.alert(element_name, locator)
170
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppAlert.new("#{element_name}", self, #{locator}, :page);end))
259
+ define_method(element_name) do
260
+ ivar_name = "@#{element_name}"
261
+ ivar = instance_variable_get(ivar_name)
262
+ return ivar if ivar
263
+ instance_variable_set(ivar_name, TestCentricity::AppAlert.new(element_name, self, locator, :page))
264
+ end
171
265
  end
172
266
 
173
267
  def self.section(section_name, class_name, locator = 0)
@@ -103,8 +103,11 @@ module TestCentricity
103
103
  obj.text
104
104
  end
105
105
  else
106
- if obj.tag_name == 'XCUIElementTypeNavigationBar'
106
+ case obj.tag_name
107
+ when 'XCUIElementTypeNavigationBar'
107
108
  obj.attribute('name')
109
+ when 'android.widget.TextView', 'android.widget.Button'
110
+ obj.text
108
111
  else
109
112
  obj.attribute('label')
110
113
  end
@@ -332,6 +335,7 @@ module TestCentricity
332
335
  obj
333
336
  end
334
337
  rescue
338
+ puts "Did not find parent object '#{@parent.get_name}' - #{@parent.get_locator}" if tries == 2 && ENV['DEBUG']
335
339
  retry if (tries -= 1) > 0
336
340
  nil
337
341
  end
@@ -1,3 +1,3 @@
1
1
  module TestCentricity
2
- VERSION = '2.3.17'
2
+ VERSION = '2.3.18'
3
3
  end
@@ -28,7 +28,12 @@ module TestCentricity
28
28
  # element :siebel_busy, "//html[contains(@class, 'siebui-busy')]"
29
29
  #
30
30
  def self.element(element_name, locator)
31
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::UIElement.new("#{element_name}", self, "#{locator}", :page);end))
31
+ define_method(element_name) do
32
+ ivar_name = "@#{element_name}"
33
+ ivar = instance_variable_get(ivar_name)
34
+ return ivar if ivar
35
+ instance_variable_set(ivar_name, TestCentricity::UIElement.new(element_name, self, locator, :page))
36
+ end
32
37
  end
33
38
 
34
39
  # Declare and instantiate a collection of generic UI Elements for this page object.
@@ -54,7 +59,12 @@ module TestCentricity
54
59
  # button :login_button, "//input[@id='submit_button']"
55
60
  #
56
61
  def self.button(element_name, locator)
57
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Button.new("#{element_name}", self, "#{locator}", :page);end))
62
+ define_method(element_name) do
63
+ ivar_name = "@#{element_name}"
64
+ ivar = instance_variable_get(ivar_name)
65
+ return ivar if ivar
66
+ instance_variable_set(ivar_name, TestCentricity::Button.new(element_name, self, locator, :page))
67
+ end
58
68
  end
59
69
 
60
70
  # Declare and instantiate a collection of buttons for this page object.
@@ -80,7 +90,12 @@ module TestCentricity
80
90
  # textfield :password_field, 'consumer_password'
81
91
  #
82
92
  def self.textfield(element_name, locator)
83
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::TextField.new("#{element_name}", self, "#{locator}", :page);end))
93
+ define_method(element_name) do
94
+ ivar_name = "@#{element_name}"
95
+ ivar = instance_variable_get(ivar_name)
96
+ return ivar if ivar
97
+ instance_variable_set(ivar_name, TestCentricity::TextField.new(element_name, self, locator, :page))
98
+ end
84
99
  end
85
100
 
86
101
  # Declare and instantiate a collection of text fields for this page object.
@@ -164,7 +179,12 @@ module TestCentricity
164
179
  # label :rollup_price_label, "//div[contains(@id, 'Rollup Item Price')]"
165
180
  #
166
181
  def self.label(element_name, locator)
167
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Label.new("#{element_name}", self, "#{locator}", :page);end))
182
+ define_method(element_name) do
183
+ ivar_name = "@#{element_name}"
184
+ ivar = instance_variable_get(ivar_name)
185
+ return ivar if ivar
186
+ instance_variable_set(ivar_name, TestCentricity::Label.new(element_name, self, locator, :page))
187
+ end
168
188
  end
169
189
 
170
190
  def self.labels(element_hash)
@@ -182,7 +202,12 @@ module TestCentricity
182
202
  # link :shopping_basket_link, "//a[@href='shopping_basket']"
183
203
  #
184
204
  def self.link(element_name, locator)
185
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Link.new("#{element_name}", self, "#{locator}", :page);end))
205
+ define_method(element_name) do
206
+ ivar_name = "@#{element_name}"
207
+ ivar = instance_variable_get(ivar_name)
208
+ return ivar if ivar
209
+ instance_variable_set(ivar_name, TestCentricity::Link.new(element_name, self, locator, :page))
210
+ end
186
211
  end
187
212
 
188
213
  def self.links(element_hash)
@@ -199,7 +224,12 @@ module TestCentricity
199
224
  # table :payments_table, "//table[@class='payments_table']"
200
225
  #
201
226
  def self.table(element_name, locator)
202
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Table.new("#{element_name}", self, "#{locator}", :page);end))
227
+ define_method(element_name) do
228
+ ivar_name = "@#{element_name}"
229
+ ivar = instance_variable_get(ivar_name)
230
+ return ivar if ivar
231
+ instance_variable_set(ivar_name, TestCentricity::Table.new(element_name, self, locator, :page))
232
+ end
203
233
  end
204
234
 
205
235
  def self.tables(element_hash)
@@ -217,7 +247,12 @@ module TestCentricity
217
247
  # selectlist :gender_select, "//select[@id='customer_gender']"
218
248
  #
219
249
  def self.selectlist(element_name, locator)
220
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::SelectList.new("#{element_name}", self, "#{locator}", :page);end))
250
+ define_method(element_name) do
251
+ ivar_name = "@#{element_name}"
252
+ ivar = instance_variable_get(ivar_name)
253
+ return ivar if ivar
254
+ instance_variable_set(ivar_name, TestCentricity::SelectList.new(element_name, self, locator, :page))
255
+ end
221
256
  end
222
257
 
223
258
  def self.selectlists(element_hash)
@@ -234,7 +269,12 @@ module TestCentricity
234
269
  # list :x_axis_list, 'g.x-axis'
235
270
  #
236
271
  def self.list(element_name, locator)
237
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::List.new("#{element_name}", self, "#{locator}", :page);end))
272
+ define_method(element_name) do
273
+ ivar_name = "@#{element_name}"
274
+ ivar = instance_variable_get(ivar_name)
275
+ return ivar if ivar
276
+ instance_variable_set(ivar_name, TestCentricity::List.new(element_name, self, locator, :page))
277
+ end
238
278
  end
239
279
 
240
280
  def self.lists(element_hash)
@@ -252,7 +292,12 @@ module TestCentricity
252
292
  # image :corporate_logo_image, "//img[@alt='MyCompany_logo']"
253
293
  #
254
294
  def self.image(element_name, locator)
255
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Image.new("#{element_name}", self, "#{locator}", :page);end))
295
+ define_method(element_name) do
296
+ ivar_name = "@#{element_name}"
297
+ ivar = instance_variable_get(ivar_name)
298
+ return ivar if ivar
299
+ instance_variable_set(ivar_name, TestCentricity::Image.new(element_name, self, locator, :page))
300
+ end
256
301
  end
257
302
 
258
303
  def self.images(element_hash)
@@ -269,7 +314,12 @@ module TestCentricity
269
314
  # filefield :attach_file, 's_SweFileName'
270
315
  #
271
316
  def self.filefield(element_name, locator)
272
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::FileField.new("#{element_name}", self, "#{locator}", :page);end))
317
+ define_method(element_name) do
318
+ ivar_name = "@#{element_name}"
319
+ ivar = instance_variable_get(ivar_name)
320
+ return ivar if ivar
321
+ instance_variable_set(ivar_name, TestCentricity::FileField.new(element_name, self, locator, :page))
322
+ end
273
323
  end
274
324
 
275
325
  def self.filefields(element_hash)
@@ -140,7 +140,12 @@ module TestCentricity
140
140
  # element :basket_header, 'div.basket_header'
141
141
  #
142
142
  def self.element(element_name, locator)
143
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::UIElement.new("#{element_name}", self, "#{locator}", :section);end))
143
+ define_method(element_name) do
144
+ ivar_name = "@#{element_name}"
145
+ ivar = instance_variable_get(ivar_name)
146
+ return ivar if ivar
147
+ instance_variable_set(ivar_name, TestCentricity::UIElement.new(element_name, self, locator, :section))
148
+ end
144
149
  end
145
150
 
146
151
  # Declare and instantiate a collection of generic UI Elements for this page section.
@@ -166,7 +171,12 @@ module TestCentricity
166
171
  # button :login_button, "//input[@id='submit_button']"
167
172
  #
168
173
  def self.button(element_name, locator)
169
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Button.new("#{element_name}", self, "#{locator}", :section);end))
174
+ define_method(element_name) do
175
+ ivar_name = "@#{element_name}"
176
+ ivar = instance_variable_get(ivar_name)
177
+ return ivar if ivar
178
+ instance_variable_set(ivar_name, TestCentricity::Button.new(element_name, self, locator, :section))
179
+ end
170
180
  end
171
181
 
172
182
  # Declare and instantiate a collection of buttons for this page section.
@@ -192,7 +202,12 @@ module TestCentricity
192
202
  # textfield :password_field, 'input#consumer_password'
193
203
  #
194
204
  def self.textfield(element_name, locator)
195
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::TextField.new("#{element_name}", self, "#{locator}", :section);end))
205
+ define_method(element_name) do
206
+ ivar_name = "@#{element_name}"
207
+ ivar = instance_variable_get(ivar_name)
208
+ return ivar if ivar
209
+ instance_variable_set(ivar_name, TestCentricity::TextField.new(element_name, self, locator, :section))
210
+ end
196
211
  end
197
212
 
198
213
  # Declare and instantiate a collection of text fields for this page section.
@@ -276,7 +291,12 @@ module TestCentricity
276
291
  # label :rollup_price_label, "//div[contains(@id, 'Rollup Item Price')]"
277
292
  #
278
293
  def self.label(element_name, locator)
279
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Label.new("#{element_name}", self, "#{locator}", :section);end))
294
+ define_method(element_name) do
295
+ ivar_name = "@#{element_name}"
296
+ ivar = instance_variable_get(ivar_name)
297
+ return ivar if ivar
298
+ instance_variable_set(ivar_name, TestCentricity::Label.new(element_name, self, locator, :section))
299
+ end
280
300
  end
281
301
 
282
302
  def self.labels(element_hash)
@@ -294,7 +314,12 @@ module TestCentricity
294
314
  # link :shopping_basket_link, "//a[@href='shopping_basket']"
295
315
  #
296
316
  def self.link(element_name, locator)
297
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Link.new("#{element_name}", self, "#{locator}", :section);end))
317
+ define_method(element_name) do
318
+ ivar_name = "@#{element_name}"
319
+ ivar = instance_variable_get(ivar_name)
320
+ return ivar if ivar
321
+ instance_variable_set(ivar_name, TestCentricity::Link.new(element_name, self, locator, :section))
322
+ end
298
323
  end
299
324
 
300
325
  def self.links(element_hash)
@@ -311,7 +336,12 @@ module TestCentricity
311
336
  # table :payments_table, "//table[@class='payments_table']"
312
337
  #
313
338
  def self.table(element_name, locator)
314
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Table.new("#{element_name}", self, "#{locator}", :section);end))
339
+ define_method(element_name) do
340
+ ivar_name = "@#{element_name}"
341
+ ivar = instance_variable_get(ivar_name)
342
+ return ivar if ivar
343
+ instance_variable_set(ivar_name, TestCentricity::Table.new(element_name, self, locator, :section))
344
+ end
315
345
  end
316
346
 
317
347
  def self.tables(element_hash)
@@ -329,7 +359,12 @@ module TestCentricity
329
359
  # selectlist :gender_select, "//select[@id='customer_gender']"
330
360
  #
331
361
  def self.selectlist(element_name, locator)
332
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::SelectList.new("#{element_name}", self, "#{locator}", :section);end))
362
+ define_method(element_name) do
363
+ ivar_name = "@#{element_name}"
364
+ ivar = instance_variable_get(ivar_name)
365
+ return ivar if ivar
366
+ instance_variable_set(ivar_name, TestCentricity::SelectList.new(element_name, self, locator, :section))
367
+ end
333
368
  end
334
369
 
335
370
  def self.selectlists(element_hash)
@@ -346,7 +381,12 @@ module TestCentricity
346
381
  # list :y_axis_list, 'g.y_axis'
347
382
  #
348
383
  def self.list(element_name, locator)
349
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::List.new("#{element_name}", self, "#{locator}", :section);end))
384
+ define_method(element_name) do
385
+ ivar_name = "@#{element_name}"
386
+ ivar = instance_variable_get(ivar_name)
387
+ return ivar if ivar
388
+ instance_variable_set(ivar_name, TestCentricity::List.new(element_name, self, locator, :section))
389
+ end
350
390
  end
351
391
 
352
392
  def self.lists(element_hash)
@@ -364,7 +404,12 @@ module TestCentricity
364
404
  # image :corporate_logo_image, "//img[@alt='MyCompany_logo']"
365
405
  #
366
406
  def self.image(element_name, locator)
367
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Image.new("#{element_name}", self, "#{locator}", :section);end))
407
+ define_method(element_name) do
408
+ ivar_name = "@#{element_name}"
409
+ ivar = instance_variable_get(ivar_name)
410
+ return ivar if ivar
411
+ instance_variable_set(ivar_name, TestCentricity::Image.new(element_name, self, locator, :section))
412
+ end
368
413
  end
369
414
 
370
415
  def self.images(element_hash)
@@ -381,7 +426,12 @@ module TestCentricity
381
426
  # filefield :attach_file, 's_SweFileName'
382
427
  #
383
428
  def self.filefield(element_name, locator)
384
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::FileField.new("#{element_name}", self, "#{locator}", :section);end))
429
+ define_method(element_name) do
430
+ ivar_name = "@#{element_name}"
431
+ ivar = instance_variable_get(ivar_name)
432
+ return ivar if ivar
433
+ instance_variable_set(ivar_name, TestCentricity::FileField.new(element_name, self, locator, :section))
434
+ end
385
435
  end
386
436
 
387
437
  def self.filefields(element_hash)
@@ -877,5 +927,6 @@ module TestCentricity
877
927
  def section_not_found_exception(section)
878
928
  raise ObjectNotFoundError.new("Section object '#{get_name}' (#{get_locator}) not found") unless section
879
929
  end
930
+
880
931
  end
881
932
  end
@@ -2,13 +2,15 @@ module TestCentricity
2
2
  class SelectList < UIElement
3
3
  attr_accessor :list_item
4
4
  attr_accessor :selected_item
5
+ attr_accessor :list_trigger
5
6
 
6
7
  def initialize(name, parent, locator, context)
7
8
  super
8
9
  @type = :selectlist
9
10
  list_spec = {
10
- :list_item => 'option',
11
- :selected_item => 'option[selected]'
11
+ :list_item => "li[class*='active-result']",
12
+ :selected_item => "li[class*='result-selected']",
13
+ :list_trigger => nil
12
14
  }
13
15
  define_list_elements(list_spec)
14
16
  end
@@ -16,12 +18,14 @@ module TestCentricity
16
18
  def define_list_elements(element_spec)
17
19
  element_spec.each do |element, value|
18
20
  case element
19
- when :list_item
20
- @list_item = value
21
- when :selected_item
22
- @selected_item = value
23
- else
24
- raise "#{element} is not a recognized selectlist element"
21
+ when :list_item
22
+ @list_item = value
23
+ when :selected_item
24
+ @selected_item = value
25
+ when :list_trigger
26
+ @list_trigger = value
27
+ else
28
+ raise "#{element} is not a recognized selectlist element"
25
29
  end
26
30
  end
27
31
  end
@@ -42,19 +46,26 @@ module TestCentricity
42
46
  def choose_option(option)
43
47
  obj, = find_element
44
48
  object_not_found_exception(obj, nil)
45
- obj.click
46
- if first(:css, "li[class*='active-result']")
49
+ if @list_trigger.nil?
50
+ obj.click
51
+ else
52
+ page.find(:css, @list_trigger).click
53
+ sleep(1)
54
+ end
55
+ if first(:css, @list_item)
47
56
  if option.is_a?(Array)
48
57
  option.each do |item|
49
- page.find(:css, "li[class*='active-result']", text: item.strip).click
58
+ page.find(:css, @list_item, text: item.strip).click
50
59
  end
51
60
  else
52
61
  if option.is_a?(Hash)
53
- page.find(:css, "li[class*='active-result']:nth-of-type(#{option[:index]})").click if option.has_key?(:index)
62
+ page.find(:css, "#{@list_item}:nth-of-type(#{option[:index]})").click if option.has_key?(:index)
63
+ page.find(:css, "#{@list_item}:nth-of-type(#{option[:value]})").click if option.has_key?(:value)
64
+ page.find(:css, "#{@list_item}:nth-of-type(#{option[:text]})").click if option.has_key?(:text)
54
65
  else
55
- options = obj.all("li[class*='active-result']").collect(&:text)
66
+ options = obj.all(@list_item).collect(&:text)
56
67
  sleep(2) unless options.include?(option)
57
- first(:css, "li[class*='active-result']", text: option).click
68
+ first(:css, @list_item, text: option).click
58
69
  end
59
70
  end
60
71
  else
@@ -78,10 +89,10 @@ module TestCentricity
78
89
  def get_options
79
90
  obj, = find_element
80
91
  object_not_found_exception(obj, nil)
81
- if first(:css, "li[class*='active-result']")
82
- obj.all("li[class*='active-result']").collect(&:text)
83
- else
92
+ if first(:css, @list_item)
84
93
  obj.all(@list_item).collect(&:text)
94
+ else
95
+ obj.all('option').collect(&:text)
85
96
  end
86
97
  end
87
98
 
@@ -97,10 +108,10 @@ module TestCentricity
97
108
  def get_option_count
98
109
  obj, = find_element
99
110
  object_not_found_exception(obj, nil)
100
- if first(:css, "li[class*='active-result']")
101
- obj.all("li[class*='active-result']").count
102
- else
111
+ if first(:css, @list_item)
103
112
  obj.all(@list_item).count
113
+ else
114
+ obj.all('option').count
104
115
  end
105
116
  end
106
117
 
@@ -123,10 +134,10 @@ module TestCentricity
123
134
  def get_selected_option
124
135
  obj, = find_element
125
136
  object_not_found_exception(obj, nil)
126
- if first(:css, "li[class*='active-result']")
127
- obj.first(:css, "li[class*='result-selected']").text
137
+ if first(:css, @list_item)
138
+ obj.first(:css, @selected_item).text
128
139
  else
129
- obj.first(@selected_item).text
140
+ obj.first('option[selected]').text
130
141
  end
131
142
  end
132
143
 
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.17
4
+ version: 2.3.18
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-08 00:00:00.000000000 Z
11
+ date: 2018-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler