testcentricity_web 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +25 -25
- data/lib/testcentricity_web/elements/checkbox.rb +9 -1
- data/lib/testcentricity_web/elements/radio.rb +9 -1
- data/lib/testcentricity_web/page_objects_helper.rb +4 -0
- data/lib/testcentricity_web/page_sections_helper.rb +11 -2
- data/lib/testcentricity_web/ui_elements_helper.rb +12 -7
- data/lib/testcentricity_web/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b39f61c69a2634fd4f5d13b3bdf839080cca35bf
|
4
|
+
data.tar.gz: 6c2bb1c66cac6070151f99d0e843c1fa68792e99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4e4eaebe5b3e2372298b302b10bc7d06ed905872acc83744b19629c70f404120116073bc251f0704d07eb59df9d95bb3d947c60ec699740a882455451c108fb
|
7
|
+
data.tar.gz: 8c7411358f090f377341bb91b791f87d14e3e1119c65060985d42f70ddb6f2f52c2120e775f1f568e313ca97d9734f6ed923d8fd262b3fd3e08966caa34ac62c
|
data/README.md
CHANGED
@@ -104,15 +104,15 @@ You define your page's **Traits** as shown below:
|
|
104
104
|
|
105
105
|
class LoginPage < TestCentricity::PageObject
|
106
106
|
trait(:page_name) { 'Login' }
|
107
|
-
trait(:page_url) {
|
108
|
-
trait(:page_locator) {
|
107
|
+
trait(:page_url) { '/sign_in' }
|
108
|
+
trait(:page_locator) { 'body.login-body' }
|
109
109
|
end
|
110
110
|
|
111
111
|
|
112
112
|
class HomePage < TestCentricity::PageObject
|
113
113
|
trait(:page_name) { 'Home' }
|
114
|
-
trait(:page_url) {
|
115
|
-
trait(:page_locator) {
|
114
|
+
trait(:page_url) { '/dashboard' }
|
115
|
+
trait(:page_locator) { 'body.dashboard }
|
116
116
|
end
|
117
117
|
|
118
118
|
|
@@ -122,14 +122,14 @@ You define your page's **Traits** as shown below:
|
|
122
122
|
|
123
123
|
class LoginPage < TestCentricity::PageObject
|
124
124
|
trait(:page_name) { 'Login' }
|
125
|
-
trait(:page_url) {
|
126
|
-
trait(:page_locator) {
|
125
|
+
trait(:page_url) { '/sign_in' }
|
126
|
+
trait(:page_locator) { 'body.login-body' }
|
127
127
|
|
128
128
|
# Login page UI elements
|
129
|
-
textfield :user_id_field,
|
130
|
-
textfield :password_field,
|
131
|
-
button :login_button,
|
132
|
-
checkbox :remember_checkbox,
|
129
|
+
textfield :user_id_field, '#userName'
|
130
|
+
textfield :password_field, '#password'
|
131
|
+
button :login_button, '#login'
|
132
|
+
checkbox :remember_checkbox, '#rememberUser'
|
133
133
|
label :error_message_label, 'div#statusBar.login-error'
|
134
134
|
end
|
135
135
|
|
@@ -149,14 +149,14 @@ the UI to hide implementation details, as shown below:
|
|
149
149
|
|
150
150
|
class LoginPage < TestCentricity::PageObject
|
151
151
|
trait(:page_name) { 'Login' }
|
152
|
-
trait(:page_url) {
|
153
|
-
trait(:page_locator) {
|
152
|
+
trait(:page_url) { '/sign_in' }
|
153
|
+
trait(:page_locator) { 'body.login-body' }
|
154
154
|
|
155
155
|
# Login page UI elements
|
156
|
-
textfield :user_id_field,
|
157
|
-
textfield :password_field,
|
158
|
-
button :login_button,
|
159
|
-
checkbox :remember_checkbox,
|
156
|
+
textfield :user_id_field, '#userName'
|
157
|
+
textfield :password_field, '#password'
|
158
|
+
button :login_button, '#login'
|
159
|
+
checkbox :remember_checkbox, '#rememberUser'
|
160
160
|
label :error_message_label, 'div#statusBar.login-error'
|
161
161
|
|
162
162
|
def login(user_id, password)
|
@@ -204,7 +204,7 @@ specifies the CSS or Xpath expression that uniquely identifies that root node ob
|
|
204
204
|
You define your page section's **Traits** as shown below:
|
205
205
|
|
206
206
|
class SearchForm < TestCentricity::PageSection
|
207
|
-
trait(:section_locator) {
|
207
|
+
trait(:section_locator) { 'form#gnav-search' }
|
208
208
|
end
|
209
209
|
|
210
210
|
|
@@ -213,11 +213,11 @@ You define your page section's **Traits** as shown below:
|
|
213
213
|
**UI Elements** are added to your **PageSection** class definition as shown below:
|
214
214
|
|
215
215
|
class SearchForm < TestCentricity::PageSection
|
216
|
-
trait(:section_locator) {
|
216
|
+
trait(:section_locator) { 'form#gnav-search' }
|
217
217
|
|
218
218
|
# Search Form UI elements
|
219
|
-
textfield :search_field,
|
220
|
-
button :search_button,
|
219
|
+
textfield :search_field, '#search-query
|
220
|
+
button :search_button, 'button[type=submit]'
|
221
221
|
end
|
222
222
|
|
223
223
|
|
@@ -226,11 +226,11 @@ You define your page section's **Traits** as shown below:
|
|
226
226
|
You can add high level methods to your **PageSection** class definition, as shown below:
|
227
227
|
|
228
228
|
class SearchForm < TestCentricity::PageSection
|
229
|
-
trait(:section_locator) {
|
229
|
+
trait(:section_locator) { 'form#gnav-search' }
|
230
230
|
|
231
231
|
# Search Form UI elements
|
232
|
-
textfield :search_field,
|
233
|
-
button :search_button,
|
232
|
+
textfield :search_field, '#search-query
|
233
|
+
button :search_button, 'button[type=submit]'
|
234
234
|
|
235
235
|
def search_for(value)
|
236
236
|
search_field.set(value)
|
@@ -245,8 +245,8 @@ You add a **PageSection Object** to its associated **Page Object** as shown belo
|
|
245
245
|
|
246
246
|
class HomePage < TestCentricity::PageObject
|
247
247
|
trait(:page_name) { 'Home' }
|
248
|
-
trait(:page_url) {
|
249
|
-
trait(:page_locator) {
|
248
|
+
trait(:page_url) { '/dashboard' }
|
249
|
+
trait(:page_locator) { 'body.dashboard }
|
250
250
|
|
251
251
|
# Home page Section Objects
|
252
252
|
section :search_form, SearchForm
|
@@ -31,7 +31,15 @@ module TestCentricity
|
|
31
31
|
obj, _ = find_element
|
32
32
|
object_not_found_exception(obj, 'Checkbox')
|
33
33
|
invalid_object_type_exception(obj, 'checkbox')
|
34
|
-
|
34
|
+
begin
|
35
|
+
obj.set(state)
|
36
|
+
rescue
|
37
|
+
unless state == obj.checked?
|
38
|
+
check_id = obj.native.attribute('id')
|
39
|
+
label = first("label[for='#{check_id}']")
|
40
|
+
label.click if label.exists?
|
41
|
+
end
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
45
|
# Set the check state of a checkbox object.
|
@@ -31,7 +31,15 @@ module TestCentricity
|
|
31
31
|
obj, _ = find_element
|
32
32
|
object_not_found_exception(obj, 'Radio')
|
33
33
|
invalid_object_type_exception(obj, 'radio')
|
34
|
-
|
34
|
+
begin
|
35
|
+
obj.set(state)
|
36
|
+
rescue
|
37
|
+
unless state == obj.checked?
|
38
|
+
check_id = obj.native.attribute('id')
|
39
|
+
label = first("label[for='#{check_id}']")
|
40
|
+
label.click if label.exists?
|
41
|
+
end
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
45
|
# Set the selected state of a radio button object.
|
@@ -244,8 +244,12 @@ module TestCentricity
|
|
244
244
|
actual = ui_object.exists?
|
245
245
|
when :enabled
|
246
246
|
actual = ui_object.enabled?
|
247
|
+
when :disabled
|
248
|
+
actual = ui_object.disabled?
|
247
249
|
when :visible
|
248
250
|
actual = ui_object.visible?
|
251
|
+
when :hidden
|
252
|
+
actual = ui_object.hidden?
|
249
253
|
when :readonly
|
250
254
|
actual = ui_object.read_only?
|
251
255
|
when :checked
|
@@ -230,7 +230,7 @@ module TestCentricity
|
|
230
230
|
# @example
|
231
231
|
# navigation_toolbar.wait_until_exists(0.5)
|
232
232
|
#
|
233
|
-
def wait_until_exists(seconds)
|
233
|
+
def wait_until_exists(seconds = nil)
|
234
234
|
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
235
235
|
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
236
236
|
wait.until { exists? }
|
@@ -244,7 +244,7 @@ module TestCentricity
|
|
244
244
|
# @example
|
245
245
|
# navigation_toolbar.wait_until_gone(5)
|
246
246
|
#
|
247
|
-
def wait_until_gone(seconds)
|
247
|
+
def wait_until_gone(seconds = nil)
|
248
248
|
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
249
249
|
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
250
250
|
wait.until { !exists? }
|
@@ -260,8 +260,12 @@ module TestCentricity
|
|
260
260
|
actual = ui_object.exists?
|
261
261
|
when :enabled
|
262
262
|
actual = ui_object.enabled?
|
263
|
+
when :disabled
|
264
|
+
actual = ui_object.disabled?
|
263
265
|
when :visible
|
264
266
|
actual = ui_object.visible?
|
267
|
+
when :hidden
|
268
|
+
actual = ui_object.hidden?
|
265
269
|
when :readonly
|
266
270
|
actual = ui_object.read_only?
|
267
271
|
when :checked
|
@@ -334,6 +338,11 @@ module TestCentricity
|
|
334
338
|
private
|
335
339
|
|
336
340
|
def find_section
|
341
|
+
wait = Selenium::WebDriver::Wait.new(timeout: Capybara.default_max_wait_time)
|
342
|
+
wait.until { find_object }
|
343
|
+
end
|
344
|
+
|
345
|
+
def find_object
|
337
346
|
locator = get_locator
|
338
347
|
saved_wait_time = Capybara.default_max_wait_time
|
339
348
|
Capybara.default_max_wait_time = 0.1
|
@@ -119,7 +119,7 @@ module TestCentricity
|
|
119
119
|
# basket_link.exists?
|
120
120
|
#
|
121
121
|
def exists?
|
122
|
-
obj, _ =
|
122
|
+
obj, _ = find_object
|
123
123
|
obj != nil
|
124
124
|
end
|
125
125
|
|
@@ -130,7 +130,7 @@ module TestCentricity
|
|
130
130
|
# remember_me_checkbox.visible?
|
131
131
|
#
|
132
132
|
def visible?
|
133
|
-
obj, type =
|
133
|
+
obj, type = find_object
|
134
134
|
exists = obj
|
135
135
|
invisible = false
|
136
136
|
if type == :css
|
@@ -189,7 +189,7 @@ module TestCentricity
|
|
189
189
|
# @example
|
190
190
|
# run_button.wait_until_exists(0.5)
|
191
191
|
#
|
192
|
-
def wait_until_exists(seconds)
|
192
|
+
def wait_until_exists(seconds = nil)
|
193
193
|
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
194
194
|
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
195
195
|
wait.until { exists? }
|
@@ -203,7 +203,7 @@ module TestCentricity
|
|
203
203
|
# @example
|
204
204
|
# logout_button.wait_until_gone(5)
|
205
205
|
#
|
206
|
-
def wait_until_gone(seconds)
|
206
|
+
def wait_until_gone(seconds = nil)
|
207
207
|
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
208
208
|
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
209
209
|
wait.until { !exists? }
|
@@ -217,7 +217,7 @@ module TestCentricity
|
|
217
217
|
# @example
|
218
218
|
# card_authorized_label.wait_until_value_is(5, 'Card authorized')
|
219
219
|
#
|
220
|
-
def wait_until_value_is(value, seconds)
|
220
|
+
def wait_until_value_is(value, seconds = nil)
|
221
221
|
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
222
222
|
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
223
223
|
wait.until { get_value == value }
|
@@ -231,7 +231,7 @@ module TestCentricity
|
|
231
231
|
# @example
|
232
232
|
# basket_grand_total_label.wait_until_value_changes(5)
|
233
233
|
#
|
234
|
-
def wait_until_value_changes(seconds)
|
234
|
+
def wait_until_value_changes(seconds = nil)
|
235
235
|
value = get_value
|
236
236
|
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
237
237
|
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
@@ -284,6 +284,11 @@ module TestCentricity
|
|
284
284
|
private
|
285
285
|
|
286
286
|
def find_element
|
287
|
+
wait = Selenium::WebDriver::Wait.new(timeout: Capybara.default_max_wait_time)
|
288
|
+
wait.until { find_object }
|
289
|
+
end
|
290
|
+
|
291
|
+
def find_object
|
287
292
|
@alt_locator.nil? ? locator = @locator : locator = @alt_locator
|
288
293
|
locator = "#{@parent.get_locator} #{locator}" if @context == :section && !@parent.get_locator.nil?
|
289
294
|
saved_wait_time = Capybara.default_max_wait_time
|
@@ -292,7 +297,7 @@ module TestCentricity
|
|
292
297
|
attributes = [:id, :xpath, :css]
|
293
298
|
type = attributes[tries]
|
294
299
|
locator = locator.gsub(" //", "//") if type == :xpath
|
295
|
-
obj = page.find(type, locator)
|
300
|
+
obj = page.find(type, locator, :visible => false)
|
296
301
|
[obj, type]
|
297
302
|
rescue
|
298
303
|
Capybara.default_max_wait_time = saved_wait_time
|
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: 0.7.
|
4
|
+
version: 0.7.1
|
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: 2016-04-
|
11
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|