testcentricity_web 4.1.10 → 4.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +92 -1
- data/README.md +301 -230
- data/lib/testcentricity_web/browser_helper.rb +2 -1
- data/lib/testcentricity_web/data_objects/environment.rb +0 -3
- data/lib/testcentricity_web/version.rb +1 -1
- data/lib/testcentricity_web/web_core/page_objects_helper.rb +39 -2
- data/lib/testcentricity_web/web_core/webdriver_helper.rb +162 -152
- data/lib/testcentricity_web/web_elements/media.rb +108 -0
- data/lib/testcentricity_web/web_elements/textfield.rb +28 -0
- data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +39 -1
- metadata +18 -162
- data/.gitignore +0 -39
- data/.idea/.name +0 -1
- data/.idea/encodings.xml +0 -6
- data/.idea/misc.xml +0 -4
- data/.idea/modules.xml +0 -8
- data/.idea/vcs.xml +0 -7
- data/.rspec +0 -4
- data/.rubocop.yml +0 -38
- data/.ruby-version +0 -1
- data/.simplecov +0 -9
- data/CODE_OF_CONDUCT.md +0 -13
- data/Gemfile +0 -6
- data/Rakefile +0 -115
- data/config/cucumber.yml +0 -171
- data/config/locales/en-US.yml +0 -56
- data/config/test_data/LOCAL_data.json +0 -15
- data/config/test_data/LOCAL_data.xls +0 -0
- data/config/test_data/LOCAL_data.yml +0 -11
- data/config/test_data/data.json +0 -25
- data/config/test_data/data.xls +0 -0
- data/config/test_data/data.yml +0 -20
- data/docker-compose.yml +0 -48
- data/features/basic_form_page_css.feature +0 -54
- data/features/basic_form_page_xpath.feature +0 -26
- data/features/custom_controls.feature +0 -29
- data/features/media_players.feature +0 -67
- data/features/step_definitions/generic_steps.rb.rb +0 -124
- data/features/step_definitions/media_steps.rb +0 -30
- data/features/support/data/form_data.rb +0 -43
- data/features/support/env.rb +0 -53
- data/features/support/hooks.rb +0 -270
- data/features/support/pages/base_test_page.rb +0 -22
- data/features/support/pages/basic_css_form_page.rb +0 -57
- data/features/support/pages/basic_form_page.rb +0 -500
- data/features/support/pages/basic_xpath_form_page.rb +0 -58
- data/features/support/pages/custom_controls_page.rb +0 -263
- data/features/support/pages/indexed_sections_page.rb +0 -57
- data/features/support/pages/media_test_page.rb +0 -207
- data/features/support/sections/header_nav.rb +0 -48
- data/features/support/sections/product_card.rb +0 -39
- data/features/support/world_data.rb +0 -12
- data/features/support/world_pages.rb +0 -18
- data/reports/.keep +0 -1
- data/spec/fixtures/page_object.rb +0 -22
- data/spec/fixtures/section_object.rb +0 -21
- data/spec/spec_helper.rb +0 -33
- data/spec/testcentricity_web/browser_spec.rb +0 -41
- data/spec/testcentricity_web/elements/audio_spec.rb +0 -68
- data/spec/testcentricity_web/elements/button_spec.rb +0 -18
- data/spec/testcentricity_web/elements/checkbox_spec.rb +0 -33
- data/spec/testcentricity_web/elements/file_field_spec.rb +0 -13
- data/spec/testcentricity_web/elements/image_spec.rb +0 -33
- data/spec/testcentricity_web/elements/label_spec.rb +0 -18
- data/spec/testcentricity_web/elements/link_spec.rb +0 -23
- data/spec/testcentricity_web/elements/list_spec.rb +0 -13
- data/spec/testcentricity_web/elements/radio_spec.rb +0 -28
- data/spec/testcentricity_web/elements/ui_element_spec.rb +0 -125
- data/spec/testcentricity_web/elements/video_spec.rb +0 -68
- data/spec/testcentricity_web/helper_specs/object_helpers_spec.rb +0 -39
- data/spec/testcentricity_web/helper_specs/string_helpers_spec.rb +0 -49
- data/spec/testcentricity_web/page_object_spec.rb +0 -90
- data/spec/testcentricity_web/section_object_spec.rb +0 -72
- data/spec/testcentricity_web/version_spec.rb +0 -7
- data/spec/testcentricity_web/webdriver_connect/grid_webdriver_spec.rb +0 -72
- data/spec/testcentricity_web/webdriver_connect/local_webdriver_spec.rb +0 -86
- data/spec/testcentricity_web/webdriver_connect/mobile_webdriver_spec.rb +0 -65
- data/test_site/basic_test_page.html +0 -269
- data/test_site/chosen/chosen-sprite.png +0 -0
- data/test_site/chosen/chosen-sprite@2x.png +0 -0
- data/test_site/chosen/chosen.css +0 -496
- data/test_site/chosen/chosen.jquery.js +0 -1359
- data/test_site/chosen/chosen.jquery.min.js +0 -3
- data/test_site/chosen/chosen.min.css +0 -11
- data/test_site/chosen/chosen.proto.js +0 -1399
- data/test_site/chosen/chosen.proto.min.js +0 -3
- data/test_site/chosen/composer.json +0 -36
- data/test_site/custom_controls_page.html +0 -629
- data/test_site/docsupport/chosen.png +0 -0
- data/test_site/docsupport/init.js +0 -11
- data/test_site/docsupport/init.proto.js +0 -16
- data/test_site/docsupport/jquery-1.12.4.min.js +0 -5
- data/test_site/docsupport/jquery-3.2.1.min.js +0 -4
- data/test_site/docsupport/oss-credit.png +0 -0
- data/test_site/docsupport/prism.css +0 -108
- data/test_site/docsupport/prism.js +0 -9
- data/test_site/docsupport/prototype-1.7.0.0.js +0 -6082
- data/test_site/docsupport/style.css +0 -219
- data/test_site/images/Blouse_Black.jpg +0 -0
- data/test_site/images/Granny.jpg +0 -0
- data/test_site/images/Printed_Dress.jpg +0 -0
- data/test_site/images/T-shirt.jpg +0 -0
- data/test_site/images/Wilder.jpg +0 -0
- data/test_site/images/You_Betcha.jpg +0 -0
- data/test_site/images/jeans3.jpg +0 -0
- data/test_site/indexed_sections_page.html +0 -215
- data/test_site/media/MIB2-subtitles-pt-BR.vtt +0 -49
- data/test_site/media/MIB2.mp4 +0 -0
- data/test_site/media/MP4_small.mp4 +0 -0
- data/test_site/media/MPS_sample.mp3 +0 -0
- data/test_site/media/bbc_scotland_report.mp3 +0 -0
- data/test_site/media/count_and_bars.mp4 +0 -0
- data/test_site/media_page.html +0 -86
- data/testcentricity_web.gemspec +0 -59
@@ -1,124 +0,0 @@
|
|
1
|
-
include TestCentricity
|
2
|
-
|
3
|
-
|
4
|
-
Given(/^I am (?:on|viewing) the (.*) page$/) do |page_name|
|
5
|
-
# find and load the specified target page
|
6
|
-
target_page = PageManager.find_page(page_name)
|
7
|
-
target_page.load_page
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
Then(/^I expect the (.*) page to be correctly displayed$/) do |page_name|
|
12
|
-
# find and verify that the specified target page is loaded
|
13
|
-
target_page = PageManager.find_page(page_name)
|
14
|
-
target_page.verify_page_exists
|
15
|
-
# verify that target page is correctly displayed
|
16
|
-
target_page.verify_page_ui
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
When(/^I populate the form fields$/) do
|
21
|
-
PageManager.current_page.populate_form
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
Then(/^I expect the form fields to be correctly populated$/) do
|
26
|
-
PageManager.current_page.verify_form_data
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
When(/^I (.*) my changes$/) do | action|
|
31
|
-
PageManager.current_page.perform_action(action.downcase.to_sym)
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
Then(/^I expect the tab order to be correct$/) do
|
36
|
-
PageManager.current_page.verify_tab_order
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
When(/^I click the (.*) navigation (?:tab|link)$/) do |page_name|
|
41
|
-
# find and navigate to the specified target page
|
42
|
-
target_page = PageManager.find_page(page_name)
|
43
|
-
target_page.navigate_to
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
Then(/^I should (?:see|be on) the (.*) page$/) do |page_name|
|
48
|
-
# find and verify that the specified target page is loaded
|
49
|
-
target_page = PageManager.find_page(page_name)
|
50
|
-
target_page.verify_page_exists
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
Then(/^I expect the (.*) page to be correctly displayed in a new browser tab$/) do |page_name|
|
55
|
-
Browsers.switch_to_new_browser_instance
|
56
|
-
Environ.set_external_page(true)
|
57
|
-
TestCentricity::WebDriverConnect.initialize_browser_size if Environ.headless
|
58
|
-
# find and verify that the specified target page is loaded
|
59
|
-
target_page = PageManager.find_page(page_name)
|
60
|
-
target_page.verify_page_exists
|
61
|
-
# verify that target page is correctly displayed
|
62
|
-
target_page.verify_page_ui
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
When(/^I (?:access|switch to) the new browser tab$/) do
|
67
|
-
Browsers.switch_to_new_browser_instance
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
When(/^I close the current browser window$/) do
|
72
|
-
Browsers.close_current_browser_window
|
73
|
-
# intercept and accept any JavaScript system or browser modals that may appear
|
74
|
-
begin
|
75
|
-
page.driver.browser.switch_to.alert.accept
|
76
|
-
switch_to_new_browser_instance
|
77
|
-
rescue
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
When(/^I close the previous browser window$/) do
|
83
|
-
Browsers.close_old_browser_instance
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
When(/^I refresh the current page$/) do
|
88
|
-
Browsers.refresh_browser unless Environ.driver == :appium
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
When(/^I navigate back$/) do
|
93
|
-
Browsers.navigate_back
|
94
|
-
end
|
95
|
-
|
96
|
-
|
97
|
-
When(/^I navigate forward$/) do
|
98
|
-
Browsers.navigate_forward
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
When(/^I delete all cookies$/) do
|
103
|
-
Browsers.delete_all_cookies
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
When(/^I set device orientation to (.*)$/) do |orientation|
|
108
|
-
Browsers.set_device_orientation(orientation.downcase.to_sym)
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
|
-
When(/^I choose custom select options by typing$/) do
|
113
|
-
custom_controls_page.set_select_options
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
When(/^I choose selectlist options by (.*)$/) do |method|
|
118
|
-
PageManager.current_page.choose_options_by(method)
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
|
-
Then(/^I expect the selected option to be displayed$/) do
|
123
|
-
PageManager.current_page.verify_chosen_options
|
124
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
When(/^I (.*) the (.*) media$/) do |action, media_type|
|
4
|
-
media_test_page.perform_action(media_type, action)
|
5
|
-
end
|
6
|
-
|
7
|
-
|
8
|
-
Then(/^the (.*) should be (.*)$/) do |media_type, state|
|
9
|
-
media_test_page.verify_media_state(media_type, state)
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
When(/^I play the (.*) with a playback speed of (.*)x$/) do |media_type, rate|
|
14
|
-
media_test_page.set_playback_rate(media_type, rate)
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
Then(/^the (.*) should play at (.*)x speed$/) do |media_type, rate|
|
19
|
-
media_test_page.verify_playback_rate(media_type, rate)
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
When(/^I set the volume of the (.*) to (.*)$/) do |media_type, volume|
|
24
|
-
media_test_page.set_volume(media_type, volume)
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
Then(/^the (.*) should have a volume of (.*)$/) do |media_type, volume|
|
29
|
-
media_test_page.verify_volume(media_type, volume)
|
30
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
class FormDataSource < TestCentricity::ExcelDataSource
|
2
|
-
def read_form_data
|
3
|
-
form_data = case ENV['DATA_SOURCE'].downcase.to_sym
|
4
|
-
when :excel
|
5
|
-
read_excel_row_data('Form_data', 'primary')
|
6
|
-
when :yaml, :json
|
7
|
-
environs.read('Form_data', 'primary')
|
8
|
-
else
|
9
|
-
raise "#{ENV['DATA_SOURCE']} is not a valid data source"
|
10
|
-
end
|
11
|
-
FormData.current = FormData.new(form_data)
|
12
|
-
end
|
13
|
-
|
14
|
-
def map_form_data(form_data)
|
15
|
-
FormData.current = FormData.new(form_data)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
class FormData < TestCentricity::DataPresenter
|
21
|
-
attribute :username, String
|
22
|
-
attribute :password, String
|
23
|
-
attribute :image_filename, String
|
24
|
-
attribute :multi_select, String
|
25
|
-
attribute :drop_down_item, String
|
26
|
-
attribute :check1, Boolean, default: false
|
27
|
-
attribute :check2, Boolean, default: false
|
28
|
-
attribute :check3, Boolean, default: false
|
29
|
-
attribute :radio_select, Integer
|
30
|
-
|
31
|
-
def initialize(data)
|
32
|
-
@username = data[:username]
|
33
|
-
@password = data[:password]
|
34
|
-
@image_filename = data[:image_filename]
|
35
|
-
@multi_select = data[:multi_select]
|
36
|
-
@drop_down_item = data[:drop_down_item]
|
37
|
-
@check1 = data[:check1]
|
38
|
-
@check2 = data[:check2]
|
39
|
-
@check3 = data[:check3]
|
40
|
-
@radio_select = data[:radio_select]
|
41
|
-
super
|
42
|
-
end
|
43
|
-
end
|
data/features/support/env.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'appium_capybara'
|
4
|
-
require 'capybara/cucumber'
|
5
|
-
require 'parallel_tests'
|
6
|
-
require 'require_all'
|
7
|
-
require 'simplecov'
|
8
|
-
require 'testcentricity_web'
|
9
|
-
|
10
|
-
include TestCentricity
|
11
|
-
|
12
|
-
coverage_report_name = "Features-#{ENV['WEB_BROWSER']}-#{ENV['SELENIUM']}" + (ENV['TEST_ENV_NUMBER'] || '')
|
13
|
-
SimpleCov.command_name("#{coverage_report_name}-#{Time.now.strftime('%Y%m%d%H%M%S%L')}")
|
14
|
-
|
15
|
-
require_relative 'world_data'
|
16
|
-
require_relative 'world_pages'
|
17
|
-
|
18
|
-
require_rel 'data'
|
19
|
-
require_rel 'sections'
|
20
|
-
require_rel 'pages'
|
21
|
-
|
22
|
-
$LOAD_PATH << './lib'
|
23
|
-
|
24
|
-
# set Capybara's default max wait time to 20 seconds
|
25
|
-
Capybara.default_max_wait_time = 20
|
26
|
-
|
27
|
-
# set the default locale and auto load all translations from config/locales/*.rb,yml.
|
28
|
-
ENV['LOCALE'] = 'en-US' unless ENV['LOCALE']
|
29
|
-
I18n.load_path += Dir['config/locales/*.{rb,yml}']
|
30
|
-
I18n.default_locale = ENV['LOCALE']
|
31
|
-
I18n.locale = ENV['LOCALE']
|
32
|
-
Faker::Config.locale = ENV['LOCALE']
|
33
|
-
|
34
|
-
# instantiate all data objects and target test environment
|
35
|
-
include WorldData
|
36
|
-
ENV['DATA_SOURCE'] = 'yaml' unless ENV['DATA_SOURCE']
|
37
|
-
environs.find_environ(ENV['TEST_ENVIRONMENT'], ENV['DATA_SOURCE'].downcase.to_sym)
|
38
|
-
WorldData.instantiate_data_objects
|
39
|
-
|
40
|
-
# instantiate all page objects
|
41
|
-
include WorldPages
|
42
|
-
WorldPages.instantiate_page_objects
|
43
|
-
|
44
|
-
# establish connection to WebDriver and target web browser
|
45
|
-
Webdrivers.cache_time = 86_400
|
46
|
-
|
47
|
-
|
48
|
-
url = if Environ.test_environment == :local
|
49
|
-
"file://#{File.dirname(__FILE__)}/../../test_site"
|
50
|
-
else
|
51
|
-
Environ.current.app_host
|
52
|
-
end
|
53
|
-
WebDriverConnect.initialize_web_driver(app_host: url)
|
data/features/support/hooks.rb
DELETED
@@ -1,270 +0,0 @@
|
|
1
|
-
|
2
|
-
BeforeAll do
|
3
|
-
# start Appium Server if command line option was specified and target browser is mobile simulator or device
|
4
|
-
if ENV['APPIUM_SERVER'] == 'run' && Environ.driver == :appium
|
5
|
-
$server = TestCentricity::AppiumServer.new
|
6
|
-
$server.start
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
AfterAll do
|
12
|
-
# terminate Appium Server if command line option was specified and target browser is mobile simulator or device
|
13
|
-
if ENV['APPIUM_SERVER'] == 'run' && Environ.driver == :appium && $server.running?
|
14
|
-
$server.stop
|
15
|
-
end
|
16
|
-
# close driver
|
17
|
-
terminate_session
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
Before do |scenario|
|
22
|
-
# if executing tests in parallel concurrent threads, print thread number with scenario name
|
23
|
-
message = Environ.parallel ? "Thread ##{Environ.process_num} | Scenario: #{scenario.name}" : "Scenario: #{scenario.name}"
|
24
|
-
log message
|
25
|
-
$initialized ||= false
|
26
|
-
unless $initialized
|
27
|
-
$initialized = true
|
28
|
-
$test_start_time = Time.now
|
29
|
-
# HTML report header information if reporting is enabled
|
30
|
-
log Environ.report_header if ENV['REPORTING']
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
After do |scenario|
|
36
|
-
# process and embed any screenshots recorded during execution of scenario
|
37
|
-
process_embed_screenshots(scenario)
|
38
|
-
# clear out any queued screenshots
|
39
|
-
Environ.reset_contexts
|
40
|
-
# close any external pages that may have been opened
|
41
|
-
if Environ.external_page
|
42
|
-
Browsers.close_current_browser_instance
|
43
|
-
begin
|
44
|
-
page.driver.browser.switch_to.alert.accept
|
45
|
-
Browsers.switch_to_new_browser_instance
|
46
|
-
rescue
|
47
|
-
end
|
48
|
-
Environ.set_external_page(false)
|
49
|
-
end
|
50
|
-
# block any JavaScript modals that may appear as a result of ending the session
|
51
|
-
Browsers.suppress_js_leave_page_modal
|
52
|
-
# close Capybara Appium driver if it was opened
|
53
|
-
Capybara.page.driver.quit if Capybara.default_driver == :appium
|
54
|
-
|
55
|
-
if ENV['QUIT_DRIVER']
|
56
|
-
terminate_session
|
57
|
-
elsif Environ.grid == :browserstack
|
58
|
-
# restart BrowserStack test sessions if test duration exceeds 110 minutes to avoid the 2 hour test limit
|
59
|
-
test_elapsed_time = Time.now - $test_start_time
|
60
|
-
if test_elapsed_time > 6600
|
61
|
-
terminate_session
|
62
|
-
log 'Restarting BrowserStack test session'
|
63
|
-
$test_start_time = Time.now
|
64
|
-
else
|
65
|
-
Capybara.reset_sessions!
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
# exclusionary Around hooks to prevent running feature/scenario on unsupported browsers, devices, or
|
72
|
-
# cloud remote browser hosting platforms. Use the following tags to block test execution:
|
73
|
-
# desktop web browsers: @!safari, @!ie, @!firefox, @!chrome, @!edge
|
74
|
-
# mobile devices: @!ipad, @!iphone
|
75
|
-
# remotely hosted browsers: @!browserstack, @!saucelabs
|
76
|
-
|
77
|
-
# block feature/scenario execution if running against Safari browser
|
78
|
-
Around('@!safari') do |scenario, block|
|
79
|
-
qualify_browser(:safari, 'Safari', scenario, block)
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
# block feature/scenario execution if running against Internet Explorer browser
|
84
|
-
Around('@!ie') do |scenario, block|
|
85
|
-
qualify_browser(:ie, 'Internet Explorer', scenario, block)
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
# block feature/scenario execution if running against Microsoft Edge browser
|
90
|
-
Around('@!edge') do |scenario, block|
|
91
|
-
qualify_browser(:edge, 'Edge', scenario, block)
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
# block feature/scenario execution if running against Chrome browser
|
96
|
-
Around('@!chrome') do |scenario, block|
|
97
|
-
qualify_browser(:chrome, 'Chrome', scenario, block)
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
|
-
# block feature/scenario execution if running against Firefox browser
|
102
|
-
Around('@!firefox') do |scenario, block|
|
103
|
-
qualify_browser(:firefox, 'Firefox', scenario, block)
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
Around('@!firefox_headless') do |scenario, block|
|
108
|
-
qualify_browser(:firefox_headless, 'Firefox headless', scenario, block)
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
|
-
# block feature/scenario execution if running against iPad mobile browser
|
113
|
-
Around('@!ipad') do |scenario, block|
|
114
|
-
qualify_device('ipad', scenario, block)
|
115
|
-
end
|
116
|
-
|
117
|
-
|
118
|
-
# block feature/scenario execution if running against iPhone mobile browser
|
119
|
-
Around('@!iphone') do |scenario, block|
|
120
|
-
qualify_device('iphone', scenario, block)
|
121
|
-
end
|
122
|
-
|
123
|
-
|
124
|
-
# block feature/scenario execution if running on Selenium Grid or cloud-hosted services
|
125
|
-
Around('@!grid') do |scenario, block|
|
126
|
-
if !Environ.grid
|
127
|
-
block.call
|
128
|
-
else
|
129
|
-
log "Scenario '#{scenario.name}' cannot be executed on Selenium Grid or cloud-hosted services."
|
130
|
-
skip_this_scenario
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
|
135
|
-
# block feature/scenario execution if running against Browserstack cloud-hosted service
|
136
|
-
Around('@!browserstack') do |scenario, block|
|
137
|
-
if Environ.grid != :browserstack
|
138
|
-
block.call
|
139
|
-
else
|
140
|
-
log "Scenario '#{scenario.name}' cannot be executed on the BrowserStack service."
|
141
|
-
skip_this_scenario
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
# block feature/scenario execution if running against Sauce Labs cloud-hosted service
|
147
|
-
Around('@!saucelabs') do |scenario, block|
|
148
|
-
if Environ.grid != :saucelabs
|
149
|
-
block.call
|
150
|
-
else
|
151
|
-
log "Scenario '#{scenario.name}' cannot be executed on the SauceLabs service."
|
152
|
-
skip_this_scenario
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
|
157
|
-
# block feature/scenario execution if running against a physical or emulated mobile device
|
158
|
-
Around('@!device') do |scenario, block|
|
159
|
-
if Environ.is_device?
|
160
|
-
log "Scenario '#{scenario.name}' cannot be executed on physical or emulated devices."
|
161
|
-
skip_this_scenario
|
162
|
-
else
|
163
|
-
block.call
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
|
168
|
-
Around('@!ios') do |scenario, block|
|
169
|
-
if Environ.device_os == :android
|
170
|
-
block.call
|
171
|
-
else
|
172
|
-
log "Scenario '#{scenario.name}' can not be executed on iOS devices."
|
173
|
-
skip_this_scenario
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
|
178
|
-
Around('@!android') do |scenario, block|
|
179
|
-
if Environ.device_os == :ios
|
180
|
-
block.call
|
181
|
-
else
|
182
|
-
log "Scenario '#{scenario.name}' can not be executed on Android devices."
|
183
|
-
skip_this_scenario
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
|
188
|
-
Around('@!mobile') do |scenario, block|
|
189
|
-
if Environ.platform == :mobile
|
190
|
-
log "Scenario '#{scenario.name}' is not executed on mobile devices or simulators."
|
191
|
-
skip_this_scenario
|
192
|
-
else
|
193
|
-
block.call
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
|
198
|
-
Around('@!headless') do |scenario, block|
|
199
|
-
if Environ.headless
|
200
|
-
log "Scenario '#{scenario.name}' is not executed on headless browsers."
|
201
|
-
skip_this_scenario
|
202
|
-
else
|
203
|
-
block.call
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
|
208
|
-
Around('@!firefox_grid') do |scenario, block|
|
209
|
-
if Environ.browser == :firefox && Environ.grid
|
210
|
-
log "Scenario '#{scenario.name}' can not be executed on grid hosted Firefox browsers."
|
211
|
-
skip_this_scenario
|
212
|
-
else
|
213
|
-
block.call
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
|
218
|
-
# supporting methods
|
219
|
-
|
220
|
-
def qualify_browser(browser_type, browser_name, scenario, block)
|
221
|
-
if Environ.browser != browser_type && ENV['HOST_BROWSER'] != browser_name.downcase
|
222
|
-
block.call
|
223
|
-
else
|
224
|
-
log "Scenario '#{scenario.name}' cannot be executed with the #{browser_name} browser."
|
225
|
-
skip_this_scenario
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
def qualify_device(device, scenario, block)
|
230
|
-
if Environ.is_device?
|
231
|
-
if Environ.device_type.include? device
|
232
|
-
log "Scenario '#{scenario.name}' cannot be executed on #{device} devices."
|
233
|
-
skip_this_scenario
|
234
|
-
else
|
235
|
-
block.call
|
236
|
-
end
|
237
|
-
else
|
238
|
-
block.call
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
def terminate_session
|
243
|
-
Capybara.page.driver.quit
|
244
|
-
Capybara.reset_sessions!
|
245
|
-
Environ.session_state = :quit
|
246
|
-
$driver_scenario_count = 0
|
247
|
-
end
|
248
|
-
|
249
|
-
def screen_shot_and_save_page(scenario)
|
250
|
-
timestamp = Time.now.strftime('%Y%m%d%H%M%S%L')
|
251
|
-
filename = scenario.nil? ? "Screenshot-#{timestamp}.png" : "Screenshot-#{scenario.__id__}-#{timestamp}.png"
|
252
|
-
path = File.join Dir.pwd, 'reports/screenshots/', filename
|
253
|
-
save_screenshot path
|
254
|
-
log "Screenshot saved at #{path}"
|
255
|
-
screen_shot = { path: path, filename: filename }
|
256
|
-
Environ.save_screen_shot(screen_shot)
|
257
|
-
attach(path, 'image/png') unless scenario.nil?
|
258
|
-
end
|
259
|
-
|
260
|
-
def process_embed_screenshots(scenario)
|
261
|
-
screen_shots = Environ.get_screen_shots
|
262
|
-
if screen_shots.count > 0
|
263
|
-
screen_shots.each do |row|
|
264
|
-
path = row[:path]
|
265
|
-
attach(path, 'image/png')
|
266
|
-
end
|
267
|
-
else
|
268
|
-
screen_shot_and_save_page(scenario) if scenario.failed?
|
269
|
-
end
|
270
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# Page Object class definition for Base Test page
|
2
|
-
|
3
|
-
class BaseTestPage < TestCentricity::PageObject
|
4
|
-
# Base Test page UI elements
|
5
|
-
label :header_label, 'h2#header'
|
6
|
-
sections header_nav: NavHeader
|
7
|
-
|
8
|
-
def navigate_to
|
9
|
-
navigator
|
10
|
-
end
|
11
|
-
|
12
|
-
def verify_page_ui
|
13
|
-
# verify page title and header
|
14
|
-
ui = {
|
15
|
-
self => { exists: true, secure: false, title: page_title },
|
16
|
-
header_label => { visible: true, caption: page_title }
|
17
|
-
}
|
18
|
-
verify_ui_states(ui)
|
19
|
-
# verify header navigation bar
|
20
|
-
header_nav.verify_nav_bar
|
21
|
-
end
|
22
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# Page Object class definition for Basic HTML Form page with CSS locators
|
2
|
-
|
3
|
-
class BasicCSSFormPage < BasicFormPage
|
4
|
-
trait(:page_name) { 'Basic CSS Form' }
|
5
|
-
trait(:page_locator) { 'form#HTMLFormElements' }
|
6
|
-
|
7
|
-
# Basic HTML Test page UI elements
|
8
|
-
textfields username_field: 'input#username',
|
9
|
-
password_field: 'input#password',
|
10
|
-
max_length_field: 'input#maxlength',
|
11
|
-
read_only_field: 'input#readonly',
|
12
|
-
number_field: 'input#number-field',
|
13
|
-
date_field: 'input#date-picker',
|
14
|
-
date_time_field: 'input#date-time-picker',
|
15
|
-
email_field: 'input#email-field',
|
16
|
-
month_field: 'input#month-field',
|
17
|
-
color_picker: 'input#color-picker',
|
18
|
-
comments_field: 'textarea#comments'
|
19
|
-
ranges slider: 'input#slider'
|
20
|
-
filefields upload_file: 'input#filename'
|
21
|
-
checkboxes check_1: 'input#check1',
|
22
|
-
check_2: 'input#check2',
|
23
|
-
check_3: 'input#check3',
|
24
|
-
check_4: 'input#check4'
|
25
|
-
radios radio_1: 'input#radio1',
|
26
|
-
radio_2: 'input#radio2',
|
27
|
-
radio_3: 'input#radio3',
|
28
|
-
radio_4: 'input#radio4'
|
29
|
-
selectlists multi_select: 'select#multipleselect',
|
30
|
-
drop_down_select: 'select#dropdown'
|
31
|
-
lists links_list: 'ul#links_list'
|
32
|
-
links link_1: 'a#link1',
|
33
|
-
link_2: 'a#link2',
|
34
|
-
link_3: 'a#link3'
|
35
|
-
tables static_table: 'table#table'
|
36
|
-
images image_1: 'img#image1',
|
37
|
-
image_2: 'img#image2',
|
38
|
-
image_3: 'img#image3'
|
39
|
-
buttons cancel_button: 'input#cancel',
|
40
|
-
submit_button: 'input#submit'
|
41
|
-
labels username_label: "label[for='username']",
|
42
|
-
password_label: "label[for='password']",
|
43
|
-
max_length_label: "label[for='maxlength']",
|
44
|
-
read_only_label: "label[for='readonly']",
|
45
|
-
number_label: "label[for='number-field']",
|
46
|
-
color_label: "label[for='color-picker']",
|
47
|
-
slider_label: "label[for='slider']",
|
48
|
-
comments_label: "label[for='comments']",
|
49
|
-
filename_label: "label[for='filename']",
|
50
|
-
checkboxes_label: 'label#checkboxes',
|
51
|
-
radios_label: 'label#radios',
|
52
|
-
multiselect_label: "label[for='multipleselect']",
|
53
|
-
dropdown_label: "label[for='dropdown']",
|
54
|
-
link_label: 'label#links',
|
55
|
-
table_label: "label[for='table']",
|
56
|
-
images_label: 'label#images'
|
57
|
-
end
|