testcentricity_web 1.0.5 → 1.0.6
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 +68 -2
- data/lib/testcentricity_web/elements/file_field.rb +14 -0
- data/lib/testcentricity_web/page_objects_helper.rb +18 -0
- data/lib/testcentricity_web/page_sections_helper.rb +72 -0
- data/lib/testcentricity_web/ui_elements_helper.rb +20 -6
- 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: 2f494b9af6b3241d6335a6f393c9b7d0e11c7243
|
4
|
+
data.tar.gz: e662186ea64b03aee0b5ec7d03dce83dcbac38f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58740657c8799577dc74e5aa9b642a35481e299d3d4f029e50a08bfb6d4397964ba7a78d4ed2703532f3022763542fcd6b17f091c36ad3538cf76df4769ac63f
|
7
|
+
data.tar.gz: d50fa04094bdcd160314e6c408540b9deecdf8552cc32d6d37449e034543b1fcd24b6085058ee489616ead22b3155d648cf77d0df66adc723340e9f785279abe
|
data/README.md
CHANGED
@@ -164,6 +164,30 @@ You define your page's **Traits** as shown below:
|
|
164
164
|
label :error_message_label, 'div#statusBar.login-error'
|
165
165
|
end
|
166
166
|
|
167
|
+
|
168
|
+
class RegistrationPage < TestCentricity::PageObject
|
169
|
+
trait(:page_name) { 'Registration' }
|
170
|
+
trait(:page_url) { '/register' }
|
171
|
+
trait(:page_locator) { 'body.registration' }
|
172
|
+
|
173
|
+
# Registration page UI elements
|
174
|
+
textfields first_name_field: 'input#firstName',
|
175
|
+
last_name_field: 'input#lastName',
|
176
|
+
email_field: 'input#email',
|
177
|
+
phone_number_field: 'input#phone',
|
178
|
+
address_field: 'input#streetAddress',
|
179
|
+
city_field: 'input#city',
|
180
|
+
post_code_field: 'input#postalCode',
|
181
|
+
password_field: 'input#password',
|
182
|
+
pword_confirm_field: 'input#passwordConfirmation'
|
183
|
+
selectlists title_select: 'select#title',
|
184
|
+
gender_select: 'select#gender',
|
185
|
+
state_select: 'select#stateProvince'
|
186
|
+
checkbox :email_opt_in_check, 'input#marketingEmailsOptIn'
|
187
|
+
button :sign_up_button, 'button#registrationSignUp'
|
188
|
+
end
|
189
|
+
|
190
|
+
|
167
191
|
Once your **Page Objects** have been instantiated, you can interact with the **UI Elements** in your **Page Objects**. An example is shown
|
168
192
|
below:
|
169
193
|
|
@@ -214,6 +238,48 @@ the UI to hide implementation details, as shown below:
|
|
214
238
|
super
|
215
239
|
end
|
216
240
|
end
|
241
|
+
|
242
|
+
|
243
|
+
class RegistrationPage < TestCentricity::PageObject
|
244
|
+
trait(:page_name) { 'Registration' }
|
245
|
+
trait(:page_url) { '/register' }
|
246
|
+
trait(:page_locator) { 'body.registration' }
|
247
|
+
|
248
|
+
# Registration page UI elements
|
249
|
+
textfields first_name_field: 'input#firstName',
|
250
|
+
last_name_field: 'input#lastName',
|
251
|
+
email_field: 'input#email',
|
252
|
+
phone_number_field: 'input#phone',
|
253
|
+
address_field: 'input#streetAddress',
|
254
|
+
city_field: 'input#city',
|
255
|
+
post_code_field: 'input#postalCode',
|
256
|
+
password_field: 'input#password',
|
257
|
+
pword_confirm_field: 'input#passwordConfirmation'
|
258
|
+
selectlists title_select: 'select#title',
|
259
|
+
gender_select: 'select#gender',
|
260
|
+
state_select: 'select#stateProvince'
|
261
|
+
checkbox :email_opt_in_check, 'input#marketingEmailsOptIn'
|
262
|
+
button :sign_up_button, 'button#registrationSignUp'
|
263
|
+
|
264
|
+
def enter_profile_data(profile)
|
265
|
+
fields = { title_select => profile.title,
|
266
|
+
first_name_field => profile.first_name,
|
267
|
+
last_name_field => profile.last_name,
|
268
|
+
gender_select => profile.gender,
|
269
|
+
phone_number_field => profile.phone,
|
270
|
+
email_field => profile.email,
|
271
|
+
address_field => profile.address,
|
272
|
+
city_field => profile.city,
|
273
|
+
state_select => profile.state,
|
274
|
+
post_code_field => profile.postal_code,
|
275
|
+
password_field => profile.password,
|
276
|
+
pword_confirm_field => profile.confirm_password
|
277
|
+
}
|
278
|
+
populate_data_fields(fields)
|
279
|
+
sign_up_button.click
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
217
283
|
|
218
284
|
|
219
285
|
Once your **Page Objects** have been instantiated, you can call your methods as shown below:
|
@@ -394,7 +460,7 @@ Include the step definitions and code below in a `page_steps.rb` or `generic_ste
|
|
394
460
|
|
395
461
|
include TestCentricity
|
396
462
|
|
397
|
-
Given(/^I am
|
463
|
+
Given(/^I am on the ([^\"]*) page$/) do |page_name|
|
398
464
|
target_page = page_dispatcher(page_name)
|
399
465
|
target_page.load_page if target_page
|
400
466
|
PageManager.set_current_page(target_page)
|
@@ -421,7 +487,7 @@ Include the step definitions and code below in a `page_steps.rb` or `generic_ste
|
|
421
487
|
end
|
422
488
|
|
423
489
|
|
424
|
-
# this method
|
490
|
+
# this method takes a page name as a parameter and returns an instance of the associated Page Object
|
425
491
|
def page_dispatcher(page_name)
|
426
492
|
page = PageManager.find_page(page_name)
|
427
493
|
raise "No page object defined for page named '#{page_name}'" unless page
|
@@ -13,5 +13,19 @@ module TestCentricity
|
|
13
13
|
page.attach_file(@locator, file_path)
|
14
14
|
Capybara.ignore_hidden_elements = true
|
15
15
|
end
|
16
|
+
|
17
|
+
def drop_files(files)
|
18
|
+
js_script = "fileList = Array();"
|
19
|
+
files.count.times do |i|
|
20
|
+
# generate a fake input selector
|
21
|
+
page.execute_script("if ($('#seleniumUpload#{i}').length == 0) { seleniumUpload#{i} = window.$('<input/>').attr({id: 'seleniumUpload#{i}', type:'file'}).appendTo('body'); }")
|
22
|
+
# attach file to the fake input selector through Capybara
|
23
|
+
attach_file("seleniumUpload#{i}", files[i])
|
24
|
+
# create the fake js event
|
25
|
+
js_script = "#{js_script} fileList.push(seleniumUpload#{i}.get(0).files[0]);"
|
26
|
+
end
|
27
|
+
# trigger the fake drop event
|
28
|
+
page.execute_script("#{js_script} e = $.Event('drop'); e.originalEvent = {dataTransfer : { files : fileList } }; $('##{@locator}').trigger(e);")
|
29
|
+
end
|
16
30
|
end
|
17
31
|
end
|
@@ -112,6 +112,15 @@ module TestCentricity
|
|
112
112
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::CheckBox.new(self, "#{locator}", :page, #{proxy});end))
|
113
113
|
end
|
114
114
|
|
115
|
+
# Declare and instantiate a collection of checkboxes for this page object.
|
116
|
+
#
|
117
|
+
# @param element_hash [Hash] names of checkboxes (as a symbol) and CSS selectors or XPath expressions that uniquely identifies checkboxes
|
118
|
+
# @example
|
119
|
+
# checkboxes hazmat_certified_check: 'input#hazmatCertified',
|
120
|
+
# epa_certified_check: 'input#epaCertified',
|
121
|
+
# dhs_certified_check: 'input#homelandSecurityCertified',
|
122
|
+
# carb_compliant_check: 'input#carbCompliant'
|
123
|
+
#
|
115
124
|
def self.checkboxes(element_hash)
|
116
125
|
element_hash.each do |element_name, locator|
|
117
126
|
checkbox(element_name, locator)
|
@@ -131,6 +140,15 @@ module TestCentricity
|
|
131
140
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Radio.new(self, "#{locator}", :page, #{proxy});end))
|
132
141
|
end
|
133
142
|
|
143
|
+
# Declare and instantiate a collection of radio buttons for this page object.
|
144
|
+
#
|
145
|
+
# @param element_hash [Hash] names of radio buttons (as a symbol) and CSS selectors or XPath expressions that uniquely identifies radio buttons
|
146
|
+
# @example
|
147
|
+
# radios visa_radio: 'input#payWithVisa',
|
148
|
+
# mastercard_radio: 'input#payWithMastercard',
|
149
|
+
# discover_radio: 'input#payWithDiscover',
|
150
|
+
# amex_radio: 'input#payWithAmEx'
|
151
|
+
#
|
134
152
|
def self.radios(element_hash)
|
135
153
|
element_hash.each do |element_name, locator|
|
136
154
|
radio(element_name, locator)
|
@@ -39,6 +39,14 @@ module TestCentricity
|
|
39
39
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::UIElement.new(self, "#{locator}", :section);end))
|
40
40
|
end
|
41
41
|
|
42
|
+
# Declare and instantiate a collection of generic UI Elements for this page section.
|
43
|
+
#
|
44
|
+
# @param element_hash [Hash] names of UI objects (as a symbol) and CSS selectors or XPath expressions that uniquely identifies objects
|
45
|
+
# @example
|
46
|
+
# elements profile_item: 'a#profile',
|
47
|
+
# settings_item: 'a#userPreferencesTrigger',
|
48
|
+
# log_out_item: 'a#logout'
|
49
|
+
#
|
42
50
|
def self.elements(element_hash)
|
43
51
|
element_hash.each do |element_name, locator|
|
44
52
|
element(element_name, locator)
|
@@ -57,6 +65,14 @@ module TestCentricity
|
|
57
65
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Button.new(self, "#{locator}", :section);end))
|
58
66
|
end
|
59
67
|
|
68
|
+
# Declare and instantiate a collection of buttons for this page section.
|
69
|
+
#
|
70
|
+
# @param element_hash [Hash] names of buttons (as a symbol) and CSS selectors or XPath expressions that uniquely identifies buttons
|
71
|
+
# @example
|
72
|
+
# buttons new_account_button: 'button#new-account',
|
73
|
+
# save_button: 'button#save',
|
74
|
+
# cancel_button: 'button#cancel'
|
75
|
+
#
|
60
76
|
def self.buttons(element_hash)
|
61
77
|
element_hash.each do |element_name, locator|
|
62
78
|
button(element_name, locator)
|
@@ -75,6 +91,16 @@ module TestCentricity
|
|
75
91
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::TextField.new(self, "#{locator}", :section);end))
|
76
92
|
end
|
77
93
|
|
94
|
+
# Declare and instantiate a collection of text fields for this page section.
|
95
|
+
#
|
96
|
+
# @param element_hash [Hash] names of text fields (as a symbol) and CSS selectors or XPath expressions that uniquely identifies text fields
|
97
|
+
# @example
|
98
|
+
# textfields name_field: 'input#Name',
|
99
|
+
# title_field: 'input#Title',
|
100
|
+
# phone_field: 'input#PhoneNumber',
|
101
|
+
# fax_field: 'input#FaxNumber',
|
102
|
+
# email_field: 'input#Email'
|
103
|
+
#
|
78
104
|
def self.textfields(element_hash)
|
79
105
|
element_hash.each do |element_name, locator|
|
80
106
|
textfield(element_name, locator)
|
@@ -94,6 +120,15 @@ module TestCentricity
|
|
94
120
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::CheckBox.new(self, "#{locator}", :section, #{proxy});end))
|
95
121
|
end
|
96
122
|
|
123
|
+
# Declare and instantiate a collection of checkboxes for this page section.
|
124
|
+
#
|
125
|
+
# @param element_hash [Hash] names of checkboxes (as a symbol) and CSS selectors or XPath expressions that uniquely identifies checkboxes
|
126
|
+
# @example
|
127
|
+
# checkboxes hazmat_certified_check: 'input#hazmatCertified',
|
128
|
+
# epa_certified_check: 'input#epaCertified',
|
129
|
+
# dhs_certified_check: 'input#homelandSecurityCertified',
|
130
|
+
# carb_compliant_check: 'input#carbCompliant'
|
131
|
+
#
|
97
132
|
def self.checkboxes(element_hash)
|
98
133
|
element_hash.each do |element_name, locator|
|
99
134
|
checkbox(element_name, locator)
|
@@ -113,6 +148,15 @@ module TestCentricity
|
|
113
148
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Radio.new(self, "#{locator}", :section, #{proxy});end))
|
114
149
|
end
|
115
150
|
|
151
|
+
# Declare and instantiate a collection of radio buttons for this page section.
|
152
|
+
#
|
153
|
+
# @param element_hash [Hash] names of radio buttons (as a symbol) and CSS selectors or XPath expressions that uniquely identifies radio buttons
|
154
|
+
# @example
|
155
|
+
# radios visa_radio: 'input#payWithVisa',
|
156
|
+
# mastercard_radio: 'input#payWithMastercard',
|
157
|
+
# discover_radio: 'input#payWithDiscover',
|
158
|
+
# amex_radio: 'input#payWithAmEx'
|
159
|
+
#
|
116
160
|
def self.radios(element_hash)
|
117
161
|
element_hash.each do |element_name, locator|
|
118
162
|
radio(element_name, locator)
|
@@ -348,6 +392,34 @@ module TestCentricity
|
|
348
392
|
raise "Section #{get_locator} remained visible after #{timeout} seconds" if exists?
|
349
393
|
end
|
350
394
|
|
395
|
+
# Wait until the Section object is visible, or until the specified wait time has expired.
|
396
|
+
#
|
397
|
+
# @param seconds [Integer or Float] wait time in seconds
|
398
|
+
# @example
|
399
|
+
# bar_chart_section.wait_until_visible(0.5)
|
400
|
+
#
|
401
|
+
def wait_until_visible(seconds = nil)
|
402
|
+
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
403
|
+
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
404
|
+
wait.until { visible? }
|
405
|
+
rescue
|
406
|
+
raise "Could not find section #{get_locator} after #{timeout} seconds" unless visible?
|
407
|
+
end
|
408
|
+
|
409
|
+
# Wait until the Section object is hidden, or until the specified wait time has expired.
|
410
|
+
#
|
411
|
+
# @param seconds [Integer or Float] wait time in seconds
|
412
|
+
# @example
|
413
|
+
# bar_chart_section.wait_until_hidden(10)
|
414
|
+
#
|
415
|
+
def wait_until_hidden(seconds = nil)
|
416
|
+
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
417
|
+
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
418
|
+
wait.until { hidden? }
|
419
|
+
rescue
|
420
|
+
raise "section #{get_locator} remained visible after #{timeout} seconds" if visible?
|
421
|
+
end
|
422
|
+
|
351
423
|
# Click at a specific location within a Section object
|
352
424
|
#
|
353
425
|
# @param x [Integer] X offset
|
@@ -208,6 +208,20 @@ module TestCentricity
|
|
208
208
|
raise "Could not find element #{@locator} after #{timeout} seconds" unless exists?
|
209
209
|
end
|
210
210
|
|
211
|
+
# Wait until the object no longer exists, or until the specified wait time has expired.
|
212
|
+
#
|
213
|
+
# @param seconds [Integer or Float] wait time in seconds
|
214
|
+
# @example
|
215
|
+
# logout_button.wait_until_gone(5)
|
216
|
+
#
|
217
|
+
def wait_until_gone(seconds = nil)
|
218
|
+
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
219
|
+
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
220
|
+
wait.until { !exists? }
|
221
|
+
rescue
|
222
|
+
raise "Element #{@locator} remained visible after #{timeout} seconds" if exists?
|
223
|
+
end
|
224
|
+
|
211
225
|
# Wait until the object is visible, or until the specified wait time has expired.
|
212
226
|
#
|
213
227
|
# @param seconds [Integer or Float] wait time in seconds
|
@@ -219,21 +233,21 @@ module TestCentricity
|
|
219
233
|
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
220
234
|
wait.until { visible? }
|
221
235
|
rescue
|
222
|
-
raise "Could not find element #{@locator} after #{timeout} seconds" unless
|
236
|
+
raise "Could not find element #{@locator} after #{timeout} seconds" unless visible?
|
223
237
|
end
|
224
238
|
|
225
|
-
# Wait until the object
|
239
|
+
# Wait until the object is hidden, or until the specified wait time has expired.
|
226
240
|
#
|
227
241
|
# @param seconds [Integer or Float] wait time in seconds
|
228
242
|
# @example
|
229
|
-
#
|
243
|
+
# run_button.wait_until_hidden(10)
|
230
244
|
#
|
231
|
-
def
|
245
|
+
def wait_until_hidden(seconds = nil)
|
232
246
|
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
233
247
|
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
234
|
-
wait.until {
|
248
|
+
wait.until { hidden? }
|
235
249
|
rescue
|
236
|
-
raise "Element #{@locator} remained visible after #{timeout} seconds" if
|
250
|
+
raise "Element #{@locator} remained visible after #{timeout} seconds" if visible?
|
237
251
|
end
|
238
252
|
|
239
253
|
# Wait until the object's value equals the specified value, or until the specified wait time has expired.
|
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: 1.0.
|
4
|
+
version: 1.0.6
|
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-08-
|
11
|
+
date: 2016-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|