testcentricity 2.4.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +29 -0
  3. data/.rspec +2 -1
  4. data/.rubocop.yml +38 -0
  5. data/.ruby-version +1 -1
  6. data/.simplecov +9 -0
  7. data/.yardopts +3 -0
  8. data/CHANGELOG.md +275 -0
  9. data/CODE_OF_CONDUCT.md +13 -0
  10. data/{LICENSE.txt → LICENSE.md} +3 -4
  11. data/README.md +938 -1378
  12. data/Rakefile +63 -1
  13. data/config/cucumber.yml +145 -0
  14. data/config/locales/en-US.yml +56 -0
  15. data/config/test_data/LOCAL_data.yml +11 -0
  16. data/config/test_data/data.yml +10 -0
  17. data/features/deep_links.feature +26 -0
  18. data/features/login.feature +30 -0
  19. data/features/navigation.feature +31 -0
  20. data/features/step_definitions/generic_steps.rb +72 -0
  21. data/features/support/android/screens/about_screen.rb +11 -0
  22. data/features/support/android/screens/base_app_screen.rb +29 -0
  23. data/features/support/android/screens/checkout_address_screen.rb +17 -0
  24. data/features/support/android/screens/checkout_payment_screen.rb +22 -0
  25. data/features/support/android/screens/login_screen.rb +18 -0
  26. data/features/support/android/screens/products_screen.rb +13 -0
  27. data/features/support/android/screens/saucebot_screen.rb +16 -0
  28. data/features/support/android/screens/webview_screen.rb +13 -0
  29. data/features/support/android/sections/nav_widgets/nav_menu.rb +39 -0
  30. data/features/support/env.rb +61 -0
  31. data/features/support/hooks.rb +135 -0
  32. data/features/support/ios/screens/about_screen.rb +11 -0
  33. data/features/support/ios/screens/base_app_screen.rb +19 -0
  34. data/features/support/ios/screens/checkout_address_screen.rb +17 -0
  35. data/features/support/ios/screens/checkout_payment_screen.rb +22 -0
  36. data/features/support/ios/screens/login_screen.rb +18 -0
  37. data/features/support/ios/screens/products_screen.rb +13 -0
  38. data/features/support/ios/screens/saucebot_screen.rb +16 -0
  39. data/features/support/ios/screens/webview_screen.rb +13 -0
  40. data/features/support/ios/sections/list_items/product_cell_item.rb +13 -0
  41. data/features/support/ios/sections/modals/base_modal.rb +23 -0
  42. data/features/support/ios/sections/modals/logout_modal.rb +6 -0
  43. data/features/support/ios/sections/modals/reset_app_state_modal.rb +6 -0
  44. data/features/support/ios/sections/nav_widgets/nav_bar.rb +31 -0
  45. data/features/support/ios/sections/nav_widgets/nav_menu.rb +41 -0
  46. data/features/support/shared_components/screens/base_app_screen.rb +31 -0
  47. data/features/support/shared_components/screens/checkout_address_screen.rb +17 -0
  48. data/features/support/shared_components/screens/checkout_payment_screen.rb +22 -0
  49. data/features/support/shared_components/screens/login_screen.rb +39 -0
  50. data/features/support/shared_components/screens/saucebot_screen.rb +17 -0
  51. data/features/support/shared_components/screens/webview_screen.rb +12 -0
  52. data/features/support/shared_components/sections/nav_menu.rb +58 -0
  53. data/features/support/world_data.rb +12 -0
  54. data/features/support/world_pages.rb +26 -0
  55. data/lib/testcentricity/app_core/appium_connect_helper.rb +355 -111
  56. data/lib/testcentricity/app_core/screen_object.rb +252 -0
  57. data/lib/testcentricity/app_core/screen_objects_helper.rb +29 -280
  58. data/lib/testcentricity/app_core/screen_section.rb +350 -0
  59. data/lib/testcentricity/app_elements/app_element_helper.rb +17 -8
  60. data/lib/testcentricity/app_elements/checkbox.rb +3 -3
  61. data/lib/testcentricity/data_objects/environment.rb +133 -39
  62. data/lib/testcentricity/version.rb +1 -1
  63. data/lib/testcentricity.rb +4 -129
  64. data/reports/.keep +1 -0
  65. data/spec/fixtures/page_object.rb +22 -0
  66. data/spec/fixtures/page_section_object.rb +21 -0
  67. data/spec/fixtures/screen_object.rb +16 -0
  68. data/spec/fixtures/screen_section_object.rb +16 -0
  69. data/spec/spec_helper.rb +28 -9
  70. data/spec/testcentricity/elements/button_spec.rb +18 -0
  71. data/spec/testcentricity/elements/checkbox_spec.rb +28 -0
  72. data/spec/testcentricity/elements/image_spec.rb +13 -0
  73. data/spec/testcentricity/elements/label_spec.rb +18 -0
  74. data/spec/testcentricity/elements/list_spec.rb +13 -0
  75. data/spec/testcentricity/elements/ui_element_spec.rb +72 -0
  76. data/spec/testcentricity/mobile/appium_connect_spec.rb +117 -0
  77. data/spec/testcentricity/mobile/screen_object_spec.rb +63 -0
  78. data/spec/testcentricity/mobile/screen_section_object_spec.rb +56 -0
  79. data/spec/testcentricity/version_spec.rb +7 -0
  80. data/spec/testcentricity/web/browser_spec.rb +41 -0
  81. data/spec/testcentricity/web/local_webdriver_spec.rb +86 -0
  82. data/spec/testcentricity/web/mobile_webdriver_spec.rb +123 -0
  83. data/spec/testcentricity/web/page_object_spec.rb +85 -0
  84. data/spec/testcentricity/web/page_section_object_spec.rb +72 -0
  85. data/testcentricity.gemspec +28 -27
  86. metadata +196 -127
  87. data/.ruby-gemset +0 -1
  88. data/Gemfile.lock +0 -93
  89. data/bin/console +0 -14
  90. data/bin/setup +0 -8
  91. data/lib/devices/devices.yml +0 -352
  92. data/lib/testcentricity/app_core/appium_server.rb +0 -69
  93. data/lib/testcentricity/app_core/screen_sections_helper.rb +0 -491
  94. data/lib/testcentricity/browser_helper.rb +0 -174
  95. data/lib/testcentricity/data_objects/data_objects_helper.rb +0 -78
  96. data/lib/testcentricity/data_objects/excel_helper.rb +0 -242
  97. data/lib/testcentricity/exception_queue_helper.rb +0 -111
  98. data/lib/testcentricity/utility_helpers.rb +0 -28
  99. data/lib/testcentricity/web_core/drag_drop_helper.rb +0 -15
  100. data/lib/testcentricity/web_core/page_objects_helper.rb +0 -711
  101. data/lib/testcentricity/web_core/page_sections_helper.rb +0 -932
  102. data/lib/testcentricity/web_core/webdriver_helper.rb +0 -588
  103. data/lib/testcentricity/web_elements/button.rb +0 -8
  104. data/lib/testcentricity/web_elements/cell_button.rb +0 -8
  105. data/lib/testcentricity/web_elements/cell_checkbox.rb +0 -38
  106. data/lib/testcentricity/web_elements/cell_element.rb +0 -69
  107. data/lib/testcentricity/web_elements/cell_image.rb +0 -8
  108. data/lib/testcentricity/web_elements/cell_radio.rb +0 -31
  109. data/lib/testcentricity/web_elements/checkbox.rb +0 -100
  110. data/lib/testcentricity/web_elements/file_field.rb +0 -45
  111. data/lib/testcentricity/web_elements/image.rb +0 -34
  112. data/lib/testcentricity/web_elements/label.rb +0 -8
  113. data/lib/testcentricity/web_elements/link.rb +0 -8
  114. data/lib/testcentricity/web_elements/list.rb +0 -100
  115. data/lib/testcentricity/web_elements/list_button.rb +0 -8
  116. data/lib/testcentricity/web_elements/list_checkbox.rb +0 -38
  117. data/lib/testcentricity/web_elements/list_element.rb +0 -61
  118. data/lib/testcentricity/web_elements/list_radio.rb +0 -31
  119. data/lib/testcentricity/web_elements/radio.rb +0 -74
  120. data/lib/testcentricity/web_elements/select_list.rb +0 -208
  121. data/lib/testcentricity/web_elements/siebel_open_ui_helper.rb +0 -15
  122. data/lib/testcentricity/web_elements/table.rb +0 -612
  123. data/lib/testcentricity/web_elements/textfield.rb +0 -114
  124. data/lib/testcentricity/web_elements/ui_elements_helper.rb +0 -532
  125. data/lib/testcentricity/world_extensions.rb +0 -26
  126. data/my_templates/default/method_details/setup.rb +0 -3
  127. data/spec/testcentricity_spec.rb +0 -9
@@ -1,49 +1,14 @@
1
- require 'capybara/cucumber'
2
1
  require 'test/unit'
3
- require 'capybara/poltergeist'
2
+ require 'appium_lib'
3
+ require 'testcentricity_web'
4
4
 
5
- require 'testcentricity/world_extensions'
6
- require 'testcentricity/exception_queue_helper'
7
- require 'testcentricity/utility_helpers'
8
5
  require 'testcentricity/version'
9
- require 'testcentricity/browser_helper'
10
-
11
- require 'testcentricity/web_core/drag_drop_helper'
12
- require 'testcentricity/web_core/page_objects_helper'
13
- require 'testcentricity/web_core/page_sections_helper'
14
- require 'testcentricity/web_core/webdriver_helper'
15
-
16
- require 'testcentricity/data_objects/data_objects_helper'
17
6
  require 'testcentricity/data_objects/environment'
18
- require 'testcentricity/data_objects/excel_helper'
19
7
 
20
- require 'testcentricity/web_elements/ui_elements_helper'
21
- require 'testcentricity/web_elements/siebel_open_ui_helper'
22
- require 'testcentricity/web_elements/button'
23
- require 'testcentricity/web_elements/checkbox'
24
- require 'testcentricity/web_elements/file_field'
25
- require 'testcentricity/web_elements/image'
26
- require 'testcentricity/web_elements/label'
27
- require 'testcentricity/web_elements/link'
28
- require 'testcentricity/web_elements/radio'
29
- require 'testcentricity/web_elements/select_list'
30
- require 'testcentricity/web_elements/list'
31
- require 'testcentricity/web_elements/table'
32
- require 'testcentricity/web_elements/textfield'
33
- require 'testcentricity/web_elements/cell_element'
34
- require 'testcentricity/web_elements/cell_button'
35
- require 'testcentricity/web_elements/cell_checkbox'
36
- require 'testcentricity/web_elements/cell_radio'
37
- require 'testcentricity/web_elements/cell_image'
38
- require 'testcentricity/web_elements/list_element'
39
- require 'testcentricity/web_elements/list_button'
40
- require 'testcentricity/web_elements/list_checkbox'
41
- require 'testcentricity/web_elements/list_radio'
42
-
43
- require 'testcentricity/app_core/appium_server'
44
8
  require 'testcentricity/app_core/appium_connect_helper'
45
9
  require 'testcentricity/app_core/screen_objects_helper'
46
- require 'testcentricity/app_core/screen_sections_helper'
10
+ require 'testcentricity/app_core/screen_object'
11
+ require 'testcentricity/app_core/screen_section'
47
12
 
48
13
  require 'testcentricity/app_elements/app_element_helper'
49
14
  require 'testcentricity/app_elements/button'
@@ -55,93 +20,3 @@ require 'testcentricity/app_elements/list'
55
20
  require 'testcentricity/app_elements/image'
56
21
  require 'testcentricity/app_elements/select_list'
57
22
  require 'testcentricity/app_elements/alert'
58
-
59
-
60
- module TestCentricity
61
- class PageManager
62
- attr_accessor :current_page
63
-
64
- @page_objects = {}
65
-
66
- def self.register_page_objects(pages)
67
- result = ''
68
- pages.each do |page_object, page_class|
69
- obj = page_class.new
70
- @page_objects[page_object] = obj unless @page_objects.has_key?(page_object)
71
- page_names = obj.page_name
72
- page_names = Array(page_names) if page_names.is_a? String
73
- page_names.each do |name|
74
- page_key = name.gsub(/\s+/, '').downcase.to_sym
75
- if page_key != page_object
76
- @page_objects[page_key] = obj unless @page_objects.has_key?(page_key)
77
- end
78
- result = "#{result}def #{page_object};@#{page_object} ||= TestCentricity::PageManager.find_page(:#{page_object});end;"
79
- end
80
- end
81
- result
82
- end
83
-
84
- # Have all PageObjects been registered?
85
- #
86
- # @return [Boolean] true if all PageObjects have been registered
87
- # @example
88
- # TestCentricity::PageManager.loaded?
89
- #
90
- def self.loaded?
91
- !@page_objects.empty?
92
- end
93
-
94
- def self.find_page(page_name)
95
- (page_name.is_a? String) ? page_id = page_name.gsub(/\s+/, '').downcase.to_sym : page_id = page_name
96
- @page_objects[page_id]
97
- end
98
-
99
- # Get the currently active PageObject
100
- #
101
- # @return [PageObject]
102
- # @example
103
- # active_page = TestCentricity::PageManager.current_page
104
- #
105
- def self.current_page
106
- @current_page
107
- end
108
-
109
- # Sets the currently active PageObject
110
- #
111
- # @param page [PageObject] Reference to the active PageObject
112
- # @example
113
- # TestCentricity::PageManager.current_page = product_search_page
114
- #
115
- def self.current_page=(page)
116
- @current_page = page
117
- end
118
- end
119
-
120
-
121
- class DataManager
122
- @data_objects = {}
123
-
124
- def self.register_data_objects(data)
125
- result = ''
126
- data.each do |data_type, data_class|
127
- @data_objects[data_type] = data_class.new unless @data_objects.has_key?(data_type)
128
- result = "#{result}def #{data_type};@#{data_type} ||= TestCentricity::DataManager.find_data_object(:#{data_type});end;"
129
- end
130
- result
131
- end
132
-
133
- def self.find_data_object(data_object)
134
- @data_objects[data_object]
135
- end
136
-
137
- # Have all DataObjects been registered?
138
- #
139
- # @return [Boolean] true if all DataObjects have been registered
140
- # @example
141
- # TestCentricity::DataManager.loaded?
142
- #
143
- def self.loaded?
144
- !@data_objects.empty?
145
- end
146
- end
147
- end
data/reports/.keep ADDED
@@ -0,0 +1 @@
1
+ Placeholder file to allow the reports folder to be saved to repository. This folder is required for Jenkins test jobs using the Cucumber Reporting plug-in.
@@ -0,0 +1,22 @@
1
+ class TestPage < TestCentricity::PageObject
2
+ trait(:page_name) { 'Basic Test Page' }
3
+ trait(:page_url) { '/basic_test_page.html' }
4
+ trait(:page_locator) { 'form#HTMLFormElements' }
5
+
6
+ elements element1: 'div#element1'
7
+ buttons button1: 'button#button1'
8
+ textfields field1: 'input#field1'
9
+ links link1: 'a#link1'
10
+ ranges range1: 'input#range1'
11
+ images image1: 'img#image1'
12
+ radios radio1: 'input#radio1'
13
+ checkboxes check1: 'input#check1'
14
+ filefields file1: 'input#file1'
15
+ labels label1: 'label#label1'
16
+ tables table1: 'table#table1'
17
+ selectlists select1: 'select#select1'
18
+ lists list1: 'ul#list1'
19
+ videos video1: 'video#video1'
20
+ audios audio1: 'audio#audio1'
21
+ sections section1: TestPageSection
22
+ end
@@ -0,0 +1,21 @@
1
+ class TestPageSection < TestCentricity::PageSection
2
+ trait(:section_locator) { 'div#section' }
3
+ trait(:section_name) { 'Basic Test Section' }
4
+
5
+ elements element1: 'div#element1'
6
+ buttons button1: 'button#button1'
7
+ textfields field1: 'input#field1'
8
+ links link1: 'a#link1'
9
+ ranges range1: 'input#range1'
10
+ images image1: 'img#image1'
11
+ radios radio1: 'input#radio1'
12
+ checkboxes check1: 'input#check1'
13
+ filefields file1: 'input#file1'
14
+ labels label1: 'label#label1'
15
+ tables table1: 'table#table1'
16
+ selectlists select1: 'select#select1'
17
+ lists list1: 'ul#list1'
18
+ videos video1: 'video#video1'
19
+ audios audio1: 'audio#audio1'
20
+ sections section2: TestPageSection
21
+ end
@@ -0,0 +1,16 @@
1
+ class TestScreen < TestCentricity::ScreenObject
2
+ trait(:page_name) { 'Basic Test Screen' }
3
+ trait(:page_locator) { { accessibility_id: 'test screen' } }
4
+
5
+ elements element1: { accessibility_id: 'element 1' }
6
+ buttons button1: { accessibility_id: 'button 1' }
7
+ textfields field1: { accessibility_id: 'text input 1' }
8
+ checkboxes check1: { accessibility_id: 'checkbox 1' }
9
+ labels label1: { accessibility_id: 'label 1' }
10
+ images image1: { accessibility_id: 'image 1' }
11
+ switches switch1: { accessibility_id: 'switch 1' }
12
+ lists list1: { accessibility_id: 'list 1' }
13
+ selectlists selectlist1: { accessibility_id: 'selectlist 1' }
14
+ alerts alert1: { accessibility_id: 'alert 1' }
15
+ sections section1: TestScreenSection
16
+ end
@@ -0,0 +1,16 @@
1
+ class TestScreenSection < TestCentricity::ScreenSection
2
+ trait(:section_locator) { { accessibility_id: 'test section' } }
3
+ trait(:section_name) { 'Basic Test Section' }
4
+
5
+ elements element1: { accessibility_id: 'element 1' }
6
+ buttons button1: { accessibility_id: 'button 1' }
7
+ textfields field1: { accessibility_id: 'text input 1' }
8
+ checkboxes check1: { accessibility_id: 'checkbox 1' }
9
+ labels label1: { accessibility_id: 'label 1' }
10
+ images image1: { accessibility_id: 'image 1' }
11
+ switches switch1: { accessibility_id: 'switch 1' }
12
+ lists list1: { accessibility_id: 'list 1' }
13
+ selectlists selectlist1: { accessibility_id: 'selectlist 1' }
14
+ alert :alert1, { accessibility_id: 'alert 1' }
15
+ sections section2: TestScreenSection
16
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,14 +1,33 @@
1
- require "bundler/setup"
2
- require "testcentricity"
1
+ # frozen_string_literal: true
3
2
 
4
- RSpec.configure do |config|
5
- # Enable flags like --only-failures and --next-failure
6
- config.example_status_persistence_file_path = ".rspec_status"
3
+ require 'capybara/rspec'
4
+ require 'require_all'
5
+ require 'simplecov'
6
+ require 'testcentricity'
7
+ require 'testcentricity_web'
8
+
9
+ require_rel 'fixtures'
10
+
11
+ include TestCentricity
12
+
13
+ SimpleCov.command_name("RSpec-#{Time.now.strftime('%Y%m%d%H%M%S')}")
7
14
 
8
- # Disable RSpec exposing methods globally on `Module` and `main`
9
- config.disable_monkey_patching!
15
+ $LOAD_PATH << './lib'
10
16
 
11
- config.expect_with :rspec do |c|
12
- c.syntax = :expect
17
+ # set the default locale and auto load all translations from config/locales/*.rb,yml.
18
+ ENV['LOCALE'] = 'en-US' unless ENV['LOCALE']
19
+ I18n.load_path += Dir['config/locales/*.{rb,yml}']
20
+ I18n.default_locale = 'en-US'
21
+ I18n.locale = ENV['LOCALE']
22
+ Faker::Config.locale = ENV['LOCALE']
23
+
24
+ # prevent Test::Unit's AutoRunner from executing during RSpec's rake task
25
+ Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
26
+
27
+ RSpec.configure do |config|
28
+ config.mock_with :rspec do |mocks|
29
+ mocks.allow_message_expectations_on_nil = true
30
+ mocks.verify_doubled_constant_names = true
31
+ mocks.verify_partial_doubles = true
13
32
  end
14
33
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe TestCentricity::AppButton, required: true do
4
+ subject(:test_button) { described_class.new(:test_button, self, { accessibility_id: 'button 1' }, :page) }
5
+
6
+ it 'returns class' do
7
+ expect(test_button.class).to eql TestCentricity::AppButton
8
+ end
9
+
10
+ it 'registers with type button' do
11
+ expect(test_button.get_object_type).to eql :button
12
+ end
13
+
14
+ it 'should click the button' do
15
+ expect(test_button).to receive(:click)
16
+ test_button.click
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe TestCentricity::AppCheckBox, required: true do
4
+ subject(:test_check) { described_class.new(:test_check, self, { accessibility_id: 'check 1' }, :page) }
5
+
6
+ it 'returns class' do
7
+ expect(test_check.class).to eql TestCentricity::AppCheckBox
8
+ end
9
+
10
+ it 'registers with type checkbox' do
11
+ expect(test_check.get_object_type).to eql :checkbox
12
+ end
13
+
14
+ it 'should check the checkbox' do
15
+ expect(test_check).to receive(:check)
16
+ test_check.check
17
+ end
18
+
19
+ it 'should uncheck the checkbox' do
20
+ expect(test_check).to receive(:uncheck)
21
+ test_check.uncheck
22
+ end
23
+
24
+ it 'should know if checkbox is checked' do
25
+ allow(test_check).to receive(:checked?).and_return(true)
26
+ expect(test_check.checked?).to eq(true)
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe TestCentricity::AppImage, required: true do
4
+ subject(:test_image) { described_class.new(:test_image, self, { accessibility_id: 'image 1' }, :page) }
5
+
6
+ it 'returns class' do
7
+ expect(test_image.class).to eql TestCentricity::AppImage
8
+ end
9
+
10
+ it 'registers with type image' do
11
+ expect(test_image.get_object_type).to eql :image
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe TestCentricity::AppLabel, required: true do
4
+ subject(:test_label) { described_class.new(:test_label, self, { accessibility_id: 'label 1' }, :page) }
5
+
6
+ it 'returns class' do
7
+ expect(test_label.class).to eql TestCentricity::AppLabel
8
+ end
9
+
10
+ it 'registers with type label' do
11
+ expect(test_label.get_object_type).to eql :label
12
+ end
13
+
14
+ it 'returns caption' do
15
+ allow(test_label).to receive(:caption).and_return('caption')
16
+ expect(test_label.caption).to eql 'caption'
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe TestCentricity::AppList, required: true do
4
+ subject(:test_list) { described_class.new(:test_list, self, { accessibility_id: 'list 1' }, :page) }
5
+
6
+ it 'returns class' do
7
+ expect(test_list.class).to eql TestCentricity::AppList
8
+ end
9
+
10
+ it 'registers with type list' do
11
+ expect(test_list.get_object_type).to eql :list
12
+ end
13
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe TestCentricity::AppUIElement, required: true do
4
+ subject(:test_element) { described_class.new(:test_element, self, { accessibility_id: 'element 1' }, :page) }
5
+
6
+ it 'returns class' do
7
+ expect(test_element.class).to eql described_class
8
+ end
9
+
10
+ it 'returns name' do
11
+ expect(test_element.get_name).to eql :test_element
12
+ end
13
+
14
+ it 'returns locator' do
15
+ expect(test_element.get_locator).to eql({ accessibility_id: 'element 1'})
16
+ end
17
+
18
+ it 'should click the element' do
19
+ allow(test_element).to receive(:click)
20
+ test_element.click
21
+ end
22
+
23
+ it 'should tap the element' do
24
+ allow(test_element).to receive(:tap)
25
+ test_element.tap
26
+ end
27
+
28
+ it 'should double tap the element' do
29
+ allow(test_element).to receive(:double_tap)
30
+ test_element.double_tap
31
+ end
32
+
33
+ it 'should know if element is visible' do
34
+ allow(test_element).to receive(:visible?).and_return(false)
35
+ expect(test_element.visible?).to eq(false)
36
+ end
37
+
38
+ it 'should know if element is hidden' do
39
+ allow(test_element).to receive(:hidden?).and_return(true)
40
+ expect(test_element.hidden?).to eq(true)
41
+ end
42
+
43
+ it 'should know if element exists' do
44
+ allow(test_element).to receive(:exists?).and_return(true)
45
+ expect(test_element.exists?).to be true
46
+ end
47
+
48
+ it 'should know if element is enabled' do
49
+ allow(test_element).to receive(:enabled?).and_return(true)
50
+ expect(test_element.enabled?).to eq(true)
51
+ end
52
+
53
+ it 'should know if element is disabled' do
54
+ allow(test_element).to receive(:disabled?).and_return(true)
55
+ expect(test_element.disabled?).to eq(true)
56
+ end
57
+
58
+ it 'should know if element is selected' do
59
+ allow(test_element).to receive(:selected?).and_return(true)
60
+ expect(test_element.selected?).to eq(true)
61
+ end
62
+
63
+ it 'returns value' do
64
+ allow(test_element).to receive(:value).and_return('value')
65
+ expect(test_element.value).to eql 'value'
66
+ end
67
+
68
+ it 'should send keys' do
69
+ allow(test_element).to receive(:send_keys).with('foo bar')
70
+ test_element.send_keys('foo bar')
71
+ end
72
+ end
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe TestCentricity::AppiumConnect, required: true do
4
+ before(:context) do
5
+ # instantiate local test environment
6
+ @environs ||= EnvironData
7
+ @environs.find_environ('LOCAL', :yaml)
8
+ ENV['SELENIUM'] = ''
9
+ ENV['WEB_BROWSER'] = 'appium'
10
+ ENV['DEVICE_TYPE'] = 'phone'
11
+ ENV['LOCALE'] = 'en-US'
12
+ ENV['LANGUAGE'] = 'en'
13
+ # start Appium server
14
+ $server = TestCentricity::AppiumServer.new
15
+ $server.start
16
+ end
17
+
18
+ context 'Mobile device simulator' do
19
+ it 'connects to iOS Simulator using environment variables' do
20
+ ENV['AUTOMATION_ENGINE'] = 'XCUITest'
21
+ ENV['APP_PLATFORM_NAME'] = 'ios'
22
+ ENV['APP_VERSION'] = '15.4'
23
+ ENV['APP_DEVICE'] = 'iPhone 13 Pro Max'
24
+ ENV['APP'] = Environ.current.ios_app_path
25
+ AppiumConnect.initialize_appium
26
+ AppiumConnect.start_driver
27
+ expect(Environ.browser).to eq(:appium)
28
+ expect(Environ.platform).to eq(:mobile)
29
+ expect(Environ.driver).to eq(:appium)
30
+ expect(Environ.device).to eq(:simulator)
31
+ expect(Environ.device_name).to eq('iPhone 13 Pro Max')
32
+ expect(Environ.device_os).to eq(:ios)
33
+ expect(Environ.device_type).to eq(:phone)
34
+ expect(Environ.device_os_version).to eq('15.4')
35
+ expect(Environ.is_ios?).to eq(true)
36
+ end
37
+
38
+ it 'connects to iOS Simulator using desired_capabilities hash' do
39
+ ENV['APP_PLATFORM_NAME'] = 'ios'
40
+ ENV['APP_VERSION'] = '15.4'
41
+ ENV['APP_DEVICE'] = 'iPhone 13 Pro Max'
42
+
43
+ capabilities = {
44
+ platformName: 'ios',
45
+ platformVersion: '15.4',
46
+ deviceName: 'iPhone 13 Pro Max',
47
+ automationName: 'XCUITest',
48
+ app: Environ.current.ios_app_path
49
+ }
50
+ AppiumConnect.initialize_appium(capabilities)
51
+ AppiumConnect.start_driver
52
+ expect(Environ.browser).to eq(:appium)
53
+ expect(Environ.platform).to eq(:mobile)
54
+ expect(Environ.driver).to eq(:appium)
55
+ expect(Environ.device).to eq(:simulator)
56
+ expect(Environ.device_name).to eq('iPhone 13 Pro Max')
57
+ expect(Environ.device_os).to eq(:ios)
58
+ expect(Environ.device_type).to eq(:phone)
59
+ expect(Environ.device_os_version).to eq('15.4')
60
+ expect(Environ.is_ios?).to eq(true)
61
+ end
62
+
63
+ it 'connects to Android Simulator using environment variables' do
64
+ ENV['AUTOMATION_ENGINE'] = 'UiAutomator2'
65
+ ENV['APP_PLATFORM_NAME'] = 'Android'
66
+ ENV['APP_VERSION'] = '12.0'
67
+ ENV['APP_DEVICE'] = 'Pixel_5_API_31'
68
+ ENV['APP'] = Environ.current.android_apk_path
69
+ AppiumConnect.initialize_appium
70
+ AppiumConnect.start_driver
71
+ expect(Environ.browser).to eq(:appium)
72
+ expect(Environ.platform).to eq(:mobile)
73
+ expect(Environ.driver).to eq(:appium)
74
+ expect(Environ.device).to eq(:simulator)
75
+ expect(Environ.device_name).to eq('Pixel_5_API_31')
76
+ expect(Environ.device_os).to eq(:android)
77
+ expect(Environ.device_type).to eq(:phone)
78
+ expect(Environ.device_os_version).to eq('12.0')
79
+ expect(Environ.is_android?).to eq(true)
80
+ end
81
+
82
+ it 'connects to Android Simulator using desired_capabilities hash' do
83
+ ENV['APP_PLATFORM_NAME'] = 'Android'
84
+ ENV['APP_VERSION'] = '12.0'
85
+ ENV['APP_DEVICE'] = 'Pixel_5_API_31'
86
+
87
+ capabilities = {
88
+ platformName: 'Android',
89
+ platformVersion: '12.0',
90
+ deviceName: 'Pixel_5_API_31',
91
+ automationName: 'UiAutomator2',
92
+ avd: 'Pixel_5_API_31',
93
+ app: Environ.current.android_apk_path
94
+ }
95
+ AppiumConnect.initialize_appium(capabilities)
96
+ AppiumConnect.start_driver
97
+ expect(Environ.browser).to eq(:appium)
98
+ expect(Environ.platform).to eq(:mobile)
99
+ expect(Environ.driver).to eq(:appium)
100
+ expect(Environ.device).to eq(:simulator)
101
+ expect(Environ.device_name).to eq('Pixel_5_API_31')
102
+ expect(Environ.device_os).to eq(:android)
103
+ expect(Environ.device_type).to eq(:phone)
104
+ expect(Environ.device_os_version).to eq('12.0')
105
+ expect(Environ.is_android?).to eq(true)
106
+ end
107
+ end
108
+
109
+ after(:each) do
110
+ AppiumConnect.quit_driver
111
+ Environ.session_state = :quit
112
+ end
113
+
114
+ after(:context) do
115
+ $server.stop if Environ.driver == :appium && $server.running?
116
+ end
117
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe TestCentricity::ScreenObject, required: true do
4
+ before :context do
5
+ @test_screen = TestScreen.new
6
+ end
7
+
8
+ context 'screen object traits' do
9
+ it 'returns page name' do
10
+ expect(@test_screen.page_name).to eq('Basic Test Screen')
11
+ end
12
+
13
+ it 'returns page locator' do
14
+ expect(@test_screen.page_locator).to eq({ accessibility_id: 'test screen' })
15
+ end
16
+
17
+ it 'responds to open_portal' do
18
+ expect(@test_screen).to respond_to(:open_portal)
19
+ end
20
+
21
+ it 'responds to load_page' do
22
+ expect(@test_screen).to respond_to(:load_page)
23
+ end
24
+
25
+ it 'responds to verify_page_exists' do
26
+ expect(@test_screen).to respond_to(:verify_page_exists)
27
+ end
28
+
29
+ it 'responds to exists?' do
30
+ expect(@test_screen).to respond_to(:exists?)
31
+ end
32
+ end
33
+
34
+ context 'page object with UI elements' do
35
+ it 'responds to element' do
36
+ expect(@test_screen).to respond_to(:element1)
37
+ end
38
+
39
+ it 'responds to button' do
40
+ expect(@test_screen).to respond_to(:button1)
41
+ end
42
+
43
+ it 'responds to textfield' do
44
+ expect(@test_screen).to respond_to(:field1)
45
+ end
46
+
47
+ it 'responds to image' do
48
+ expect(@test_screen).to respond_to(:image1)
49
+ end
50
+
51
+ it 'responds to switch' do
52
+ expect(@test_screen).to respond_to(:switch1)
53
+ end
54
+
55
+ it 'responds to checkbox' do
56
+ expect(@test_screen).to respond_to(:check1)
57
+ end
58
+
59
+ it 'responds to section' do
60
+ expect(@test_screen).to respond_to(:section1)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe TestCentricity::ScreenSection, required: true do
4
+ before :context do
5
+ @test_page = TestScreen.new
6
+ @test_section = @test_page.section1
7
+ end
8
+
9
+ context 'section object traits' do
10
+ it 'returns section name' do
11
+ expect(@test_section.section_name).to eq('Basic Test Section')
12
+ end
13
+
14
+ it 'returns section locator' do
15
+ expect(@test_section.get_locator).to eq([{ accessibility_id: 'test section' }])
16
+ end
17
+
18
+ it 'returns class' do
19
+ expect(@test_section.class).to eql TestScreenSection
20
+ end
21
+
22
+ it 'registers with type section' do
23
+ expect(@test_section.get_object_type).to eql :section
24
+ end
25
+ end
26
+
27
+ context 'section object with UI elements' do
28
+ it 'responds to element' do
29
+ expect(@test_section).to respond_to(:element1)
30
+ end
31
+
32
+ it 'responds to button' do
33
+ expect(@test_section).to respond_to(:button1)
34
+ end
35
+
36
+ it 'responds to textfield' do
37
+ expect(@test_section).to respond_to(:field1)
38
+ end
39
+
40
+ it 'responds to image' do
41
+ expect(@test_section).to respond_to(:image1)
42
+ end
43
+
44
+ it 'responds to switch' do
45
+ expect(@test_section).to respond_to(:switch1)
46
+ end
47
+
48
+ it 'responds to checkbox' do
49
+ expect(@test_section).to respond_to(:check1)
50
+ end
51
+
52
+ it 'responds to section' do
53
+ expect(@test_section).to respond_to(:section2)
54
+ end
55
+ end
56
+ end