testcentricity_web 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +95 -12
- data/lib/testcentricity_web/browser_helper.rb +8 -0
- data/lib/testcentricity_web/elements/select_list.rb +6 -0
- data/lib/testcentricity_web/page_objects_helper.rb +116 -28
- data/lib/testcentricity_web/page_sections_helper.rb +86 -26
- data/lib/testcentricity_web/ui_elements_helper.rb +4 -0
- 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: 47950cb4c712070298ad6deb05d1b50ae5f18009
|
4
|
+
data.tar.gz: 567501e936e2fcbac0a57e1c866cb921afc5d7b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b13b00820983439f0bbe49be197f975d10ec163b8cfc72f27b4a0e4333fdb57697acd41276ec533036f4e8429d5dd420c9df7417db8201f223a9da7ebe7af7a5
|
7
|
+
data.tar.gz: 0bdcf538a51a41cd76150c5b424f013cf06fa1548b5b8a91c2eba2eb07f927104e8fa37ebf33a30936ca305386c69f15784e9f42b3e1cedb1df3b5b23880a42e
|
data/README.md
CHANGED
@@ -102,13 +102,18 @@ test automation project. You define new **Page Objects** as shown below:
|
|
102
102
|
end
|
103
103
|
|
104
104
|
|
105
|
+
class RegistrationPage < TestCentricity::PageObject
|
106
|
+
end
|
107
|
+
|
108
|
+
|
105
109
|
### Adding Traits to your Page Object
|
106
110
|
|
107
111
|
Web pages typically have names and URLs associated with them. Web pages also typically have a unique object or attribute that, when present,
|
108
112
|
indicates that the page's contents have fully loaded.
|
109
113
|
|
110
114
|
The `page_name` trait is registered with the **PageManager** object, which includes a `find_page` method that takes a page name as a
|
111
|
-
parameter and returns an instance of the associated **Page Object**.
|
115
|
+
parameter and returns an instance of the associated **Page Object**. If you intend to use the **PageManager**, you must define a `page_name`
|
116
|
+
trait for each of the **Page Objects** to be registered.
|
112
117
|
|
113
118
|
A `page_url` trait should be defined if a page can be directly loaded using a URL. If you set Capybara's `app_host`, or specify a base URL
|
114
119
|
when calling the `WebDriverConnect.initialize_web_driver` method, then your `page_url` trait can be the relative URL slug that will
|
@@ -135,6 +140,13 @@ You define your page's **Traits** as shown below:
|
|
135
140
|
end
|
136
141
|
|
137
142
|
|
143
|
+
class RegistrationPage < TestCentricity::PageObject
|
144
|
+
trait(:page_name) { 'Registration' }
|
145
|
+
trait(:page_url) { '/register' }
|
146
|
+
trait(:page_locator) { 'body.registration' }
|
147
|
+
end
|
148
|
+
|
149
|
+
|
138
150
|
### Adding UI Elements to your Page Object
|
139
151
|
|
140
152
|
**UI Elements** are added to your **Page Object** class definition as shown below:
|
@@ -196,6 +208,7 @@ the UI to hide implementation details, as shown below:
|
|
196
208
|
password_field => { :visible => true, :enabled => true, :value => '', :placeholder => 'Password' },
|
197
209
|
remember_checkbox => { :exists => true, :enabled => true, :checked => false },
|
198
210
|
forgot_password_link => { :visible => true, :value => 'Forgot your password?' },
|
211
|
+
error_message_label => { :visible => false }
|
199
212
|
}
|
200
213
|
verify_ui_states(ui)
|
201
214
|
super
|
@@ -331,6 +344,7 @@ to be instantiated by **PageManager**:
|
|
331
344
|
{ :login_page => LoginPage,
|
332
345
|
:home_page => HomePage,
|
333
346
|
:registration_page => RegistrationPage,
|
347
|
+
:search_results_page => SearchResultsPage,
|
334
348
|
:products_grid_page => ProductsCollectionPage,
|
335
349
|
:product_detail_page => ProductDetailPage,
|
336
350
|
:shopping_basket_page => ShoppingBasketPage,
|
@@ -353,14 +367,75 @@ executed:
|
|
353
367
|
include WorldPages
|
354
368
|
WorldPages.instantiate_page_objects
|
355
369
|
|
370
|
+
**NOTE:** If you intend to use the **PageManager**, you must define a `page_name` trait for each of the **Page Objects** to be registered.
|
371
|
+
|
372
|
+
|
373
|
+
### Leveraging the PageManager from Cucumber
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
Scenario Outline: Verify Home page navigation links
|
378
|
+
Given I am on the Home page
|
379
|
+
When I click the <page> navigation link
|
380
|
+
Then I expect the <page> page to be correctly displayed
|
381
|
+
|
382
|
+
Examples:
|
383
|
+
|page |
|
384
|
+
|Registration |
|
385
|
+
|My Account |
|
386
|
+
|Terms & Conditions |
|
387
|
+
|Privacy Policy |
|
388
|
+
|FAQs |
|
389
|
+
|Refunds & Cancellations |
|
390
|
+
|Contact US |
|
391
|
+
|
392
|
+
|
393
|
+
Include the step definitions and code below in a `page_steps.rb` or `generic_steps.rb` file in the `features/step_definitions` folder:
|
394
|
+
|
395
|
+
include TestCentricity
|
396
|
+
|
397
|
+
Given(/^I am (?:on|viewing) the ([^\"]*) page$/) do |page_name|
|
398
|
+
target_page = page_dispatcher(page_name)
|
399
|
+
target_page.load_page if target_page
|
400
|
+
PageManager.set_current_page(target_page)
|
401
|
+
end
|
402
|
+
|
403
|
+
When(/^I click the ([^\"]*) navigation link$/) do |link_name|
|
404
|
+
target_page = page_dispatcher(link_name)
|
405
|
+
target_page.navigate_to if target_page
|
406
|
+
end
|
407
|
+
|
408
|
+
Then(/^I expect to see the ([^\"]*) page$/) do |page_name|
|
409
|
+
target_page = page_dispatcher(page_name)
|
410
|
+
target_page.verify_page_exists if target_page
|
411
|
+
PageManager.set_current_page(target_page)
|
412
|
+
end
|
413
|
+
|
414
|
+
Then(/^I expect the ([^\"]*) page to be correctly displayed$/) do |page_name|
|
415
|
+
target_page = page_dispatcher(page_name)
|
416
|
+
if target_page
|
417
|
+
target_page.verify_page_exists
|
418
|
+
target_page.verify_page_ui
|
419
|
+
PageManager.set_current_page(target_page)
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
|
424
|
+
# this method that takes a page name as a parameter and returns an instance of the associated Page Object
|
425
|
+
def page_dispatcher(page_name)
|
426
|
+
page = PageManager.find_page(page_name)
|
427
|
+
raise "No page object defined for page named '#{page_name}'" unless page
|
428
|
+
page
|
429
|
+
end
|
430
|
+
|
356
431
|
|
357
432
|
|
358
433
|
## Connecting to a Web Browser
|
359
434
|
|
360
|
-
The `WebDriverConnect.initialize_web_driver` method configures the appropriate selenium-webdriver capabilities required to establish a
|
435
|
+
The `TestCentricity::WebDriverConnect.initialize_web_driver` method configures the appropriate selenium-webdriver capabilities required to establish a
|
361
436
|
connection with a target web browser, and sets the base host URL of the web site you are running your tests against.
|
362
437
|
|
363
|
-
The `WebDriverConnect.initialize_web_driver` method accepts a single optional parameter - the base host URL. Cucumber **Environment
|
438
|
+
The `TestCentricity::WebDriverConnect.initialize_web_driver` method accepts a single optional parameter - the base host URL. Cucumber **Environment
|
364
439
|
Variables** are used to specify the target local or remote web browser, and the various webdriver capability parameters required to configure
|
365
440
|
the connection.
|
366
441
|
|
@@ -427,8 +502,9 @@ to `chrome`.
|
|
427
502
|
|
428
503
|
### Mobile Safari browser on iOS Simulators
|
429
504
|
|
430
|
-
You can run your mobile web tests against the mobile Safari browser on simulated iOS devices using Appium and XCode on OS X. You must install XCode
|
431
|
-
|
505
|
+
You can run your mobile web tests against the mobile Safari browser on simulated iOS devices using Appium and XCode on OS X. You must install XCode, the
|
506
|
+
iOS version-specific device simulators for XCode, and Appium. You must ensure that the `appium_capybara` gem is installed and required as described in
|
507
|
+
**section 2.4 (Setup - Using Appium)** above.
|
432
508
|
|
433
509
|
Appium must be running prior to invoking Cucumber to run your features/scenarios.
|
434
510
|
|
@@ -460,7 +536,8 @@ staging server inside your LAN, you must set the `TUNNELING` Environment Variabl
|
|
460
536
|
#### Remote desktop browsers on the BrowserStack service
|
461
537
|
|
462
538
|
For remotely hosted desktop web browsers on the BrowserStack service, the following **Environment Variables** must be set as described in
|
463
|
-
the table below. Refer to the [Browserstack-specific capabilities chart page](https://www.browserstack.com/automate/capabilities#capabilities-browserstack)
|
539
|
+
the table below. Refer to the [Browserstack-specific capabilities chart page](https://www.browserstack.com/automate/capabilities#capabilities-browserstack)
|
540
|
+
for information regarding the specific capabilities.
|
464
541
|
|
465
542
|
**Environment Variable** | **Description**
|
466
543
|
--------------- | ----------------
|
@@ -479,7 +556,8 @@ the table below. Refer to the [Browserstack-specific capabilities chart page](ht
|
|
479
556
|
#### Remote mobile browsers on the BrowserStack service
|
480
557
|
|
481
558
|
For remotely hosted mobile web browsers on the BrowserStack service, the following **Environment Variables** must be set as described in
|
482
|
-
the table below. Refer to the [Browserstack-specific capabilities chart page](https://www.browserstack.com/automate/capabilities#capabilities-browserstack)
|
559
|
+
the table below. Refer to the [Browserstack-specific capabilities chart page](https://www.browserstack.com/automate/capabilities#capabilities-browserstack)
|
560
|
+
for information regarding the specific capabilities.
|
483
561
|
|
484
562
|
**Environment Variable** | **Description**
|
485
563
|
--------------- | ----------------
|
@@ -497,7 +575,8 @@ the table below. Refer to the [Browserstack-specific capabilities chart page](ht
|
|
497
575
|
#### Remote desktop browsers on the CrossBrowserTesting service
|
498
576
|
|
499
577
|
For remotely hosted desktop web browsers on the CrossBrowserTesting service, the following **Environment Variables** must be set as described in
|
500
|
-
the table below. Use the Configuration Wizard on the [Start a Selenium Test page](https://app.crossbrowsertesting.com/selenium/run) to obtain
|
578
|
+
the table below. Use the Configuration Wizard on the [Start a Selenium Test page](https://app.crossbrowsertesting.com/selenium/run) to obtain
|
579
|
+
information regarding the specific capabilities.
|
501
580
|
|
502
581
|
**Environment Variable** | **Description**
|
503
582
|
--------------- | ----------------
|
@@ -513,7 +592,8 @@ the table below. Use the Configuration Wizard on the [Start a Selenium Test page
|
|
513
592
|
#### Remote mobile browsers on the CrossBrowserTesting service
|
514
593
|
|
515
594
|
For remotely hosted mobile web browsers on the CrossBrowserTesting service, the following **Environment Variables** must be set as described in
|
516
|
-
the table below. Use the Configuration Wizard on the [Start a Selenium Test page](https://app.crossbrowsertesting.com/selenium/run) to obtain
|
595
|
+
the table below. Use the Configuration Wizard on the [Start a Selenium Test page](https://app.crossbrowsertesting.com/selenium/run) to obtain
|
596
|
+
information regarding the specific capabilities.
|
517
597
|
|
518
598
|
**Environment Variable** | **Description**
|
519
599
|
--------------- | ----------------
|
@@ -529,7 +609,8 @@ the table below. Use the Configuration Wizard on the [Start a Selenium Test page
|
|
529
609
|
#### Remote desktop browsers on the Sauce Labs service
|
530
610
|
|
531
611
|
For remotely hosted desktop web browsers on the Sauce Labs service, the following **Environment Variables** must be set as described in
|
532
|
-
the table below. Use the Selenium API on the [Platform Configurator page](https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/) to obtain
|
612
|
+
the table below. Use the Selenium API on the [Platform Configurator page](https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/) to obtain
|
613
|
+
information regarding the specific capabilities.
|
533
614
|
|
534
615
|
**Environment Variable** | **Description**
|
535
616
|
--------------- | ----------------
|
@@ -546,7 +627,8 @@ the table below. Use the Selenium API on the [Platform Configurator page](https:
|
|
546
627
|
#### Remote mobile browsers on the Sauce Labs service
|
547
628
|
|
548
629
|
For remotely hosted mobile web browsers on the Sauce Labs service, the following **Environment Variables** must be set as described in
|
549
|
-
the table below. Use the Selenium API on the [Platform Configurator page](https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/) to obtain
|
630
|
+
the table below. Use the Selenium API on the [Platform Configurator page](https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/) to obtain
|
631
|
+
information regarding the specific capabilities.
|
550
632
|
|
551
633
|
**Environment Variable** | **Description**
|
552
634
|
--------------- | ----------------
|
@@ -564,7 +646,8 @@ the table below. Use the Selenium API on the [Platform Configurator page](https:
|
|
564
646
|
#### Remote desktop browsers on the TestingBot service
|
565
647
|
|
566
648
|
For remotely hosted desktop web browsers on the TestingBot service, the following **Environment Variables** must be set as described in
|
567
|
-
the table below. Refer to the [TestingBot List of Available Browsers page](https://testingbot.com/support/getting-started/browsers.html) for information
|
649
|
+
the table below. Refer to the [TestingBot List of Available Browsers page](https://testingbot.com/support/getting-started/browsers.html) for information
|
650
|
+
regarding the specific capabilities.
|
568
651
|
|
569
652
|
**Environment Variable** | **Description**
|
570
653
|
--------------- | ----------------
|
@@ -64,6 +64,14 @@ module TestCentricity
|
|
64
64
|
Capybara.page.driver.browser.switch_to.window(Capybara.page.driver.browser.window_handles.last)
|
65
65
|
end
|
66
66
|
|
67
|
+
def self.suppress_js_alerts
|
68
|
+
page.execute_script("window.alert = function() {}")
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.suppress_js_leave_page_modal
|
72
|
+
page.execute_script('window.onbeforeunload = null')
|
73
|
+
end
|
74
|
+
|
67
75
|
def self.delete_all_cookies
|
68
76
|
if Capybara.current_driver == :selenium
|
69
77
|
browser = Capybara.current_session.driver.browser
|
@@ -80,6 +80,8 @@ module TestCentricity
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
alias :get_list_items :get_options
|
84
|
+
|
83
85
|
# Return the number of options in a select box object.
|
84
86
|
# Supports standard HTML select objects and Chosen select objects.
|
85
87
|
#
|
@@ -97,6 +99,8 @@ module TestCentricity
|
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
102
|
+
alias :get_item_count :get_option_count
|
103
|
+
|
100
104
|
def verify_options(expected, enqueue = false)
|
101
105
|
actual = get_options
|
102
106
|
enqueue ?
|
@@ -121,6 +125,8 @@ module TestCentricity
|
|
121
125
|
end
|
122
126
|
end
|
123
127
|
|
128
|
+
alias :selected? :get_selected_option
|
129
|
+
|
124
130
|
# Select the specified option in a Siebel OUI select box object.
|
125
131
|
#
|
126
132
|
# @param option [String] text of option to select
|
@@ -12,7 +12,7 @@ module TestCentricity
|
|
12
12
|
# @param block [&block] trait value
|
13
13
|
# @example
|
14
14
|
# trait(:page_name) { 'Shopping Basket' }
|
15
|
-
# trait(:page_url) {
|
15
|
+
# trait(:page_url) { '/shopping_basket' }
|
16
16
|
# trait(:page_locator) { "//body[@class='shopping_baskets']" }
|
17
17
|
#
|
18
18
|
def self.trait(trait_name, &block)
|
@@ -31,30 +31,74 @@ module TestCentricity
|
|
31
31
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::UIElement.new(self, "#{locator}", :page);end))
|
32
32
|
end
|
33
33
|
|
34
|
+
# Declare and instantiate a collection of generic UI Elements for this page object.
|
35
|
+
#
|
36
|
+
# @param element_hash [Hash] names of UI objects (as a symbol) and CSS selectors or XPath expressions that uniquely identifies objects
|
37
|
+
# @example
|
38
|
+
# elements profile_item: 'a#profile',
|
39
|
+
# settings_item: 'a#userPreferencesTrigger',
|
40
|
+
# log_out_item: 'a#logout'
|
41
|
+
#
|
42
|
+
def self.elements(element_hash)
|
43
|
+
element_hash.each do |element_name, locator|
|
44
|
+
element(element_name, locator)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
34
48
|
# Declare and instantiate a button UI Element for this page object.
|
35
49
|
#
|
36
50
|
# @param element_name [Symbol] name of button object (as a symbol)
|
37
51
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
38
52
|
# @example
|
39
|
-
# button :checkout_button,
|
53
|
+
# button :checkout_button, 'button.checkout_button'
|
40
54
|
# button :login_button, "//input[@id='submit_button']"
|
41
55
|
#
|
42
56
|
def self.button(element_name, locator)
|
43
57
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Button.new(self, "#{locator}", :page);end))
|
44
58
|
end
|
45
59
|
|
60
|
+
# Declare and instantiate a collection of buttons for this page object.
|
61
|
+
#
|
62
|
+
# @param element_hash [Hash] names of buttons (as a symbol) and CSS selectors or XPath expressions that uniquely identifies buttons
|
63
|
+
# @example
|
64
|
+
# buttons new_account_button: 'button#new-account',
|
65
|
+
# save_button: 'button#save',
|
66
|
+
# cancel_button: 'button#cancel'
|
67
|
+
#
|
68
|
+
def self.buttons(element_hash)
|
69
|
+
element_hash.each do |element_name, locator|
|
70
|
+
button(element_name, locator)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
46
74
|
# Declare and instantiate a text field UI Element for this page object.
|
47
75
|
#
|
48
76
|
# @param element_name [Symbol] name of text field object (as a symbol)
|
49
77
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
50
78
|
# @example
|
51
79
|
# textfield :user_id_field, "//input[@id='UserName']"
|
52
|
-
# textfield :password_field,
|
80
|
+
# textfield :password_field, 'consumer_password'
|
53
81
|
#
|
54
82
|
def self.textfield(element_name, locator)
|
55
83
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::TextField.new(self, "#{locator}", :page);end))
|
56
84
|
end
|
57
85
|
|
86
|
+
# Declare and instantiate a collection of text fields for this page object.
|
87
|
+
#
|
88
|
+
# @param element_hash [Hash] names of text fields (as a symbol) and CSS selectors or XPath expressions that uniquely identifies text fields
|
89
|
+
# @example
|
90
|
+
# textfields name_field: 'input#Name',
|
91
|
+
# title_field: 'input#Title',
|
92
|
+
# phone_field: 'input#PhoneNumber',
|
93
|
+
# fax_field: 'input#FaxNumber',
|
94
|
+
# email_field: 'input#Email'
|
95
|
+
#
|
96
|
+
def self.textfields(element_hash)
|
97
|
+
element_hash.each do |element_name, locator|
|
98
|
+
textfield(element_name, locator)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
58
102
|
# Declare and instantiate a checkbox UI Element for this page object.
|
59
103
|
#
|
60
104
|
# @param element_name [Symbol] name of checkbox object (as a symbol)
|
@@ -62,12 +106,18 @@ module TestCentricity
|
|
62
106
|
# @param proxy [Symbol] Optional name (as a symbol) of proxy object to receive click actions
|
63
107
|
# @example
|
64
108
|
# checkbox :remember_checkbox, "//input[@id='RememberUser']"
|
65
|
-
# checkbox :accept_terms_checkbox,
|
109
|
+
# checkbox :accept_terms_checkbox, 'input#accept_terms_conditions', :accept_terms_label
|
66
110
|
#
|
67
111
|
def self.checkbox(element_name, locator, proxy = nil)
|
68
112
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::CheckBox.new(self, "#{locator}", :page, #{proxy});end))
|
69
113
|
end
|
70
114
|
|
115
|
+
def self.checkboxes(element_hash)
|
116
|
+
element_hash.each do |element_name, locator|
|
117
|
+
checkbox(element_name, locator)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
71
121
|
# Declare and instantiate a radio button UI Element for this page object.
|
72
122
|
#
|
73
123
|
# @param element_name [Symbol] name of radio object (as a symbol)
|
@@ -75,12 +125,18 @@ module TestCentricity
|
|
75
125
|
# @param proxy [Symbol] Optional name (as a symbol) of proxy object to receive click actions
|
76
126
|
# @example
|
77
127
|
# radio :accept_terms_radio, "//input[@id='Accept_Terms']"
|
78
|
-
# radio :decline_terms_radio,
|
128
|
+
# radio :decline_terms_radio, '#decline_terms_conditions', :decline_terms_label
|
79
129
|
#
|
80
130
|
def self.radio(element_name, locator, proxy = nil)
|
81
131
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Radio.new(self, "#{locator}", :page, #{proxy});end))
|
82
132
|
end
|
83
133
|
|
134
|
+
def self.radios(element_hash)
|
135
|
+
element_hash.each do |element_name, locator|
|
136
|
+
radio(element_name, locator)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
84
140
|
# Declare and instantiate a label UI Element for this page object.
|
85
141
|
#
|
86
142
|
# @param element_name [Symbol] name of label object (as a symbol)
|
@@ -93,22 +149,34 @@ module TestCentricity
|
|
93
149
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Label.new(self, "#{locator}", :page);end))
|
94
150
|
end
|
95
151
|
|
152
|
+
def self.labels(element_hash)
|
153
|
+
element_hash.each do |element_name, locator|
|
154
|
+
label(element_name, locator)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
96
158
|
# Declare and instantiate a link UI Element for this page object.
|
97
159
|
#
|
98
160
|
# @param element_name [Symbol] name of link object (as a symbol)
|
99
161
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
100
162
|
# @example
|
101
|
-
# link :registration_link,
|
163
|
+
# link :registration_link, 'a.account-nav__link.register'
|
102
164
|
# link :shopping_basket_link, "//a[@href='shopping_basket']"
|
103
165
|
#
|
104
166
|
def self.link(element_name, locator)
|
105
167
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Link.new(self, "#{locator}", :page);end))
|
106
168
|
end
|
107
169
|
|
170
|
+
def self.links(element_hash)
|
171
|
+
element_hash.each do |element_name, locator|
|
172
|
+
link(element_name, locator)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
108
176
|
# Declare and instantiate a table UI Element for this page object.
|
109
177
|
#
|
110
178
|
# @param element_name [Symbol] name of table object (as a symbol)
|
111
|
-
# @param locator [String]
|
179
|
+
# @param locator [String] XPath expression that uniquely identifies object
|
112
180
|
# @example
|
113
181
|
# table :payments_table, "//table[@class='payments_table']"
|
114
182
|
#
|
@@ -116,47 +184,71 @@ module TestCentricity
|
|
116
184
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Table.new(self, "#{locator}", :page);end))
|
117
185
|
end
|
118
186
|
|
187
|
+
def self.tables(element_hash)
|
188
|
+
element_hash.each do |element_name, locator|
|
189
|
+
table(element_name, locator)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
119
193
|
# Declare and instantiate a select list UI Element for this page object.
|
120
194
|
#
|
121
195
|
# @param element_name [Symbol] name of select list object (as a symbol)
|
122
196
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
123
197
|
# @example
|
124
|
-
# selectlist :category_selector,
|
198
|
+
# selectlist :category_selector, 'select#search_form_category_chosen'
|
125
199
|
# selectlist :gender_select, "//select[@id='customer_gender']"
|
126
200
|
#
|
127
201
|
def self.selectlist(element_name, locator)
|
128
202
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::SelectList.new(self, "#{locator}", :page);end))
|
129
203
|
end
|
130
204
|
|
205
|
+
def self.selectlists(element_hash)
|
206
|
+
element_hash.each do |element_name, locator|
|
207
|
+
selectlist(element_name, locator)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
131
211
|
# Declare and instantiate a list UI Element for this page object.
|
132
212
|
#
|
133
213
|
# @param element_name [Symbol] name of list object (as a symbol)
|
134
214
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
135
215
|
# @example
|
136
|
-
# list :x_axis_list,
|
216
|
+
# list :x_axis_list, 'g.x-axis'
|
137
217
|
#
|
138
218
|
def self.list(element_name, locator)
|
139
219
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::List.new(self, "#{locator}", :page);end))
|
140
220
|
end
|
141
221
|
|
222
|
+
def self.lists(element_hash)
|
223
|
+
element_hash.each do |element_name, locator|
|
224
|
+
list(element_name, locator)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
142
228
|
# Declare and instantiate an image UI Element for this page object.
|
143
229
|
#
|
144
230
|
# @param element_name [Symbol] name of image object (as a symbol)
|
145
231
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
146
232
|
# @example
|
147
|
-
# image :basket_item_image,
|
233
|
+
# image :basket_item_image, 'div.product_image'
|
148
234
|
# image :corporate_logo_image, "//img[@alt='MyCompany_logo']"
|
149
235
|
#
|
150
236
|
def self.image(element_name, locator)
|
151
237
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Image.new(self, "#{locator}", :page);end))
|
152
238
|
end
|
153
239
|
|
240
|
+
def self.images(element_hash)
|
241
|
+
element_hash.each do |element_name, locator|
|
242
|
+
image(element_name, locator)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
154
246
|
# Declare and instantiate a File Field UI Element for this page object.
|
155
247
|
#
|
156
248
|
# @param element_name [Symbol] name of file field object (as a symbol)
|
157
249
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
158
250
|
# @example
|
159
|
-
# filefield :attach_file,
|
251
|
+
# filefield :attach_file, 's_SweFileName'
|
160
252
|
#
|
161
253
|
def self.filefield(element_name, locator)
|
162
254
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::FileField.new(self, "#{locator}", :page);end))
|
@@ -173,6 +265,12 @@ module TestCentricity
|
|
173
265
|
class_eval(%Q(def #{section_name.to_s};@#{section_name.to_s} ||= #{class_name.to_s}.new(self, "#{locator}", :page);end))
|
174
266
|
end
|
175
267
|
|
268
|
+
def self.sections(section_hash)
|
269
|
+
section_hash.each do |section_name, class_name|
|
270
|
+
section(section_name, class_name)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
176
274
|
def open_portal
|
177
275
|
environment = Environ.current
|
178
276
|
environment.hostname.blank? ?
|
@@ -187,6 +285,7 @@ module TestCentricity
|
|
187
285
|
end
|
188
286
|
|
189
287
|
def verify_page_exists
|
288
|
+
raise "Page object #{self.class.name} does not have a page_locator trait defined" unless defined?(page_locator)
|
190
289
|
unless page.has_selector?(page_locator)
|
191
290
|
body_class = find(:xpath, '//body')[:class]
|
192
291
|
error_message = "Expected page to have selector '#{page_locator}' but found '#{body_class}' instead.\nURL of page loaded = #{URI.parse(current_url)}"
|
@@ -224,6 +323,7 @@ module TestCentricity
|
|
224
323
|
# home_page.exists?
|
225
324
|
#
|
226
325
|
def exists?
|
326
|
+
raise "Page object #{self.class.name} does not have a page_locator trait defined" unless defined?(page_locator)
|
227
327
|
saved_wait_time = Capybara.default_max_wait_time
|
228
328
|
Capybara.default_max_wait_time = 0.1
|
229
329
|
tries ||= 2
|
@@ -268,12 +368,8 @@ module TestCentricity
|
|
268
368
|
when :checked
|
269
369
|
actual = ui_object.checked?
|
270
370
|
when :selected
|
271
|
-
|
272
|
-
|
273
|
-
else
|
274
|
-
actual = ui_object.selected?
|
275
|
-
end
|
276
|
-
when :value
|
371
|
+
actual = ui_object.selected?
|
372
|
+
when :value, :caption
|
277
373
|
actual = ui_object.get_value
|
278
374
|
when :maxlength
|
279
375
|
actual = ui_object.get_max_length
|
@@ -284,17 +380,9 @@ module TestCentricity
|
|
284
380
|
when :placeholder
|
285
381
|
actual = ui_object.get_placeholder
|
286
382
|
when :options, :items, :list_items
|
287
|
-
|
288
|
-
actual = ui_object.get_options
|
289
|
-
else
|
290
|
-
actual = ui_object.get_list_items
|
291
|
-
end
|
383
|
+
actual = ui_object.get_list_items
|
292
384
|
when :optioncount, :itemcount
|
293
|
-
|
294
|
-
actual = ui_object.get_option_count
|
295
|
-
else
|
296
|
-
actual = ui_object.get_item_count
|
297
|
-
end
|
385
|
+
actual = ui_object.get_item_count
|
298
386
|
when :column_headers
|
299
387
|
actual = ui_object.get_header_columns
|
300
388
|
when :siebel_options
|
@@ -355,7 +443,7 @@ module TestCentricity
|
|
355
443
|
# email_field => 'p.pumperknickle4876@google.com',
|
356
444
|
# mailing_list_check => 'Yes'
|
357
445
|
# }
|
358
|
-
#
|
446
|
+
# populate_data_fields(data)
|
359
447
|
#
|
360
448
|
def populate_data_fields(data)
|
361
449
|
data.each do | data_field, data_param |
|
@@ -33,36 +33,54 @@ module TestCentricity
|
|
33
33
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
34
34
|
# @example
|
35
35
|
# element :undo_record_item, "//li[@rn='Undo Record']/a"
|
36
|
-
# element :basket_header,
|
36
|
+
# element :basket_header, 'div.basket_header'
|
37
37
|
#
|
38
38
|
def self.element(element_name, locator)
|
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
|
+
def self.elements(element_hash)
|
43
|
+
element_hash.each do |element_name, locator|
|
44
|
+
element(element_name, locator)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
42
48
|
# Declare and instantiate a button UI Element for this page section.
|
43
49
|
#
|
44
50
|
# @param element_name [Symbol] name of button object (as a symbol)
|
45
51
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
46
52
|
# @example
|
47
|
-
# button :checkout_button,
|
53
|
+
# button :checkout_button, 'button.checkout_button'
|
48
54
|
# button :login_button, "//input[@id='submit_button']"
|
49
55
|
#
|
50
56
|
def self.button(element_name, locator)
|
51
57
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Button.new(self, "#{locator}", :section);end))
|
52
58
|
end
|
53
59
|
|
60
|
+
def self.buttons(element_hash)
|
61
|
+
element_hash.each do |element_name, locator|
|
62
|
+
button(element_name, locator)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
54
66
|
# Declare and instantiate a text field UI Element for this page section.
|
55
67
|
#
|
56
68
|
# @param element_name [Symbol] name of text field object (as a symbol)
|
57
69
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
58
70
|
# @example
|
59
71
|
# textfield :user_id_field, "//input[@id='UserName']"
|
60
|
-
# textfield :password_field,
|
72
|
+
# textfield :password_field, 'input#consumer_password'
|
61
73
|
#
|
62
74
|
def self.textfield(element_name, locator)
|
63
75
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::TextField.new(self, "#{locator}", :section);end))
|
64
76
|
end
|
65
77
|
|
78
|
+
def self.textfields(element_hash)
|
79
|
+
element_hash.each do |element_name, locator|
|
80
|
+
textfield(element_name, locator)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
66
84
|
# Declare and instantiate a checkbox UI Element for this page section.
|
67
85
|
#
|
68
86
|
# @param element_name [Symbol] name of checkbox object (as a symbol)
|
@@ -70,12 +88,18 @@ module TestCentricity
|
|
70
88
|
# @param proxy [Symbol] Optional name (as a symbol) of proxy object to receive click actions
|
71
89
|
# @example
|
72
90
|
# checkbox :remember_checkbox, "//input[@id='RememberUser']"
|
73
|
-
# checkbox :accept_terms_checkbox,
|
91
|
+
# checkbox :accept_terms_checkbox, 'input#accept_terms_conditions', :accept_terms_label
|
74
92
|
#
|
75
93
|
def self.checkbox(element_name, locator, proxy = nil)
|
76
94
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::CheckBox.new(self, "#{locator}", :section, #{proxy});end))
|
77
95
|
end
|
78
96
|
|
97
|
+
def self.checkboxes(element_hash)
|
98
|
+
element_hash.each do |element_name, locator|
|
99
|
+
checkbox(element_name, locator)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
79
103
|
# Declare and instantiate a radio button UI Element for this page section.
|
80
104
|
#
|
81
105
|
# @param element_name [Symbol] name of radio object (as a symbol)
|
@@ -83,12 +107,18 @@ module TestCentricity
|
|
83
107
|
# @param proxy [Symbol] Optional name (as a symbol) of proxy object to receive click actions
|
84
108
|
# @example
|
85
109
|
# radio :accept_terms_radio, "//input[@id='Accept_Terms']"
|
86
|
-
# radio :decline_terms_radio,
|
110
|
+
# radio :decline_terms_radio, 'input#decline_terms_conditions', :decline_terms_label
|
87
111
|
#
|
88
112
|
def self.radio(element_name, locator, proxy = nil)
|
89
113
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Radio.new(self, "#{locator}", :section, #{proxy});end))
|
90
114
|
end
|
91
115
|
|
116
|
+
def self.radios(element_hash)
|
117
|
+
element_hash.each do |element_name, locator|
|
118
|
+
radio(element_name, locator)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
92
122
|
# Declare and instantiate a label UI Element for this page section.
|
93
123
|
#
|
94
124
|
# @param element_name [Symbol] name of label object (as a symbol)
|
@@ -101,18 +131,30 @@ module TestCentricity
|
|
101
131
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Label.new(self, "#{locator}", :section);end))
|
102
132
|
end
|
103
133
|
|
134
|
+
def self.labels(element_hash)
|
135
|
+
element_hash.each do |element_name, locator|
|
136
|
+
label(element_name, locator)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
104
140
|
# Declare and instantiate a link UI Element for this page section.
|
105
141
|
#
|
106
142
|
# @param element_name [Symbol] name of link object (as a symbol)
|
107
143
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
108
144
|
# @example
|
109
|
-
# link :registration_link,
|
145
|
+
# link :registration_link, 'a.account-nav__link.register'
|
110
146
|
# link :shopping_basket_link, "//a[@href='shopping_basket']"
|
111
147
|
#
|
112
148
|
def self.link(element_name, locator)
|
113
149
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Link.new(self, "#{locator}", :section);end))
|
114
150
|
end
|
115
151
|
|
152
|
+
def self.links(element_hash)
|
153
|
+
element_hash.each do |element_name, locator|
|
154
|
+
link(element_name, locator)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
116
158
|
# Declare and instantiate a table UI Element for this page section.
|
117
159
|
#
|
118
160
|
# @param element_name [Symbol] name of table object (as a symbol)
|
@@ -124,18 +166,30 @@ module TestCentricity
|
|
124
166
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Table.new(self, "#{locator}", :section);end))
|
125
167
|
end
|
126
168
|
|
169
|
+
def self.tables(element_hash)
|
170
|
+
element_hash.each do |element_name, locator|
|
171
|
+
table(element_name, locator)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
127
175
|
# Declare and instantiate a select list UI Element for this page section.
|
128
176
|
#
|
129
177
|
# @param element_name [Symbol] name of select list object (as a symbol)
|
130
178
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
131
179
|
# @example
|
132
|
-
# selectlist :category_selector,
|
180
|
+
# selectlist :category_selector, 'select#search_form_category_chosen'
|
133
181
|
# selectlist :gender_select, "//select[@id='customer_gender']"
|
134
182
|
#
|
135
183
|
def self.selectlist(element_name, locator)
|
136
184
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::SelectList.new(self, "#{locator}", :section);end))
|
137
185
|
end
|
138
186
|
|
187
|
+
def self.selectlists(element_hash)
|
188
|
+
element_hash.each do |element_name, locator|
|
189
|
+
selectlist(element_name, locator)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
139
193
|
# Declare and instantiate a list UI Element for this page section.
|
140
194
|
#
|
141
195
|
# @param element_name [Symbol] name of list object (as a symbol)
|
@@ -147,24 +201,36 @@ module TestCentricity
|
|
147
201
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::List.new(self, "#{locator}", :section);end))
|
148
202
|
end
|
149
203
|
|
204
|
+
def self.lists(element_hash)
|
205
|
+
element_hash.each do |element_name, locator|
|
206
|
+
list(element_name, locator)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
150
210
|
# Declare and instantiate an image UI Element for this page section.
|
151
211
|
#
|
152
212
|
# @param element_name [Symbol] name of image object (as a symbol)
|
153
213
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
154
214
|
# @example
|
155
|
-
# image :basket_item_image,
|
215
|
+
# image :basket_item_image, 'div.product_image'
|
156
216
|
# image :corporate_logo_image, "//img[@alt='MyCompany_logo']"
|
157
217
|
#
|
158
218
|
def self.image(element_name, locator)
|
159
219
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Image.new(self, "#{locator}", :section);end))
|
160
220
|
end
|
161
221
|
|
222
|
+
def self.images(element_hash)
|
223
|
+
element_hash.each do |element_name, locator|
|
224
|
+
image(element_name, locator)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
162
228
|
# Declare and instantiate a File Field UI Element for this page section.
|
163
229
|
#
|
164
230
|
# @param element_name [Symbol] name of file field object (as a symbol)
|
165
231
|
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
166
232
|
# @example
|
167
|
-
# filefield :attach_file,
|
233
|
+
# filefield :attach_file, 's_SweFileName'
|
168
234
|
#
|
169
235
|
def self.filefield(element_name, locator)
|
170
236
|
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::FileField.new(self, "#{locator}", :section);end))
|
@@ -181,6 +247,12 @@ module TestCentricity
|
|
181
247
|
class_eval(%Q(def #{section_name.to_s};@#{section_name.to_s} ||= #{class_name.to_s}.new(self, "#{locator}", :section);end))
|
182
248
|
end
|
183
249
|
|
250
|
+
def self.sections(section_hash)
|
251
|
+
section_hash.each do |section_name, class_name|
|
252
|
+
section(section_name, class_name)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
184
256
|
def get_locator
|
185
257
|
(@locator.empty? && defined?(section_locator)) ? locator = section_locator : locator = @locator
|
186
258
|
(@context == :section && !@parent.nil? && !@parent.get_locator.nil?) ? "#{@parent.get_locator}|#{locator}" : locator
|
@@ -308,12 +380,8 @@ module TestCentricity
|
|
308
380
|
when :checked
|
309
381
|
actual = ui_object.checked?
|
310
382
|
when :selected
|
311
|
-
|
312
|
-
|
313
|
-
else
|
314
|
-
actual = ui_object.selected?
|
315
|
-
end
|
316
|
-
when :value
|
383
|
+
actual = ui_object.selected?
|
384
|
+
when :value, :caption
|
317
385
|
actual = ui_object.get_value
|
318
386
|
when :maxlength
|
319
387
|
actual = ui_object.get_max_length
|
@@ -324,17 +392,9 @@ module TestCentricity
|
|
324
392
|
when :placeholder
|
325
393
|
actual = ui_object.get_placeholder
|
326
394
|
when :options, :items, :list_items
|
327
|
-
|
328
|
-
actual = ui_object.get_options
|
329
|
-
else
|
330
|
-
actual = ui_object.get_list_items
|
331
|
-
end
|
395
|
+
actual = ui_object.get_list_items
|
332
396
|
when :optioncount, :itemcount
|
333
|
-
|
334
|
-
actual = ui_object.get_option_count
|
335
|
-
else
|
336
|
-
actual = ui_object.get_item_count
|
337
|
-
end
|
397
|
+
actual = ui_object.get_item_count
|
338
398
|
when :column_headers
|
339
399
|
actual = ui_object.get_header_columns
|
340
400
|
when :siebel_options
|
@@ -396,7 +456,7 @@ module TestCentricity
|
|
396
456
|
# organ_donor_check => 'Yes',
|
397
457
|
# dnr_on_file_check => 'Yes'
|
398
458
|
# }
|
399
|
-
#
|
459
|
+
# populate_data_fields(data)
|
400
460
|
#
|
401
461
|
def populate_data_fields(data)
|
402
462
|
data.each do | data_field, data_param |
|
@@ -276,6 +276,8 @@ module TestCentricity
|
|
276
276
|
end
|
277
277
|
end
|
278
278
|
|
279
|
+
alias :get_caption :get_value
|
280
|
+
|
279
281
|
def verify_value(expected, enqueue = false)
|
280
282
|
actual = get_value
|
281
283
|
enqueue ?
|
@@ -283,6 +285,8 @@ module TestCentricity
|
|
283
285
|
assert_equal(expected.strip, actual.strip, "Expected #{@locator} to display '#{expected}' but found '#{actual}'")
|
284
286
|
end
|
285
287
|
|
288
|
+
alias :verify_caption :verify_value
|
289
|
+
|
286
290
|
# Hover the cursor over an object
|
287
291
|
#
|
288
292
|
# @example
|
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.4
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|