testcentricity_web 2.1.8.2 → 2.1.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +27 -0
  3. data/.rubocop.yml +41 -0
  4. data/.yardopts +2 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE.txt +28 -0
  7. data/README.md +1438 -0
  8. data/Rakefile +1 -0
  9. data/lib/devices/devices.yml +280 -0
  10. data/lib/testcentricity_web.rb +140 -0
  11. data/lib/testcentricity_web/browser_helper.rb +173 -0
  12. data/lib/testcentricity_web/data_objects_helper.rb +78 -0
  13. data/lib/testcentricity_web/drag_drop_helper.rb +15 -0
  14. data/lib/testcentricity_web/elements/button.rb +8 -0
  15. data/lib/testcentricity_web/elements/cell_button.rb +8 -0
  16. data/lib/testcentricity_web/elements/cell_checkbox.rb +38 -0
  17. data/lib/testcentricity_web/elements/cell_element.rb +62 -0
  18. data/lib/testcentricity_web/elements/cell_image.rb +8 -0
  19. data/lib/testcentricity_web/elements/cell_radio.rb +31 -0
  20. data/lib/testcentricity_web/elements/checkbox.rb +99 -0
  21. data/lib/testcentricity_web/elements/file_field.rb +45 -0
  22. data/lib/testcentricity_web/elements/image.rb +34 -0
  23. data/lib/testcentricity_web/elements/label.rb +8 -0
  24. data/lib/testcentricity_web/elements/link.rb +8 -0
  25. data/lib/testcentricity_web/elements/list.rb +54 -0
  26. data/lib/testcentricity_web/elements/list_button.rb +8 -0
  27. data/lib/testcentricity_web/elements/list_checkbox.rb +38 -0
  28. data/lib/testcentricity_web/elements/list_element.rb +51 -0
  29. data/lib/testcentricity_web/elements/list_radio.rb +31 -0
  30. data/lib/testcentricity_web/elements/radio.rb +73 -0
  31. data/lib/testcentricity_web/elements/select_list.rb +189 -0
  32. data/lib/testcentricity_web/elements/table.rb +473 -0
  33. data/lib/testcentricity_web/elements/textfield.rb +84 -0
  34. data/lib/testcentricity_web/environment.rb +249 -0
  35. data/lib/testcentricity_web/excel_helper.rb +242 -0
  36. data/lib/testcentricity_web/exception_queue_helper.rb +47 -0
  37. data/lib/testcentricity_web/page_objects_helper.rb +656 -0
  38. data/lib/testcentricity_web/page_sections_helper.rb +811 -0
  39. data/lib/testcentricity_web/siebel_open_ui_helper.rb +15 -0
  40. data/lib/testcentricity_web/ui_elements_helper.rb +425 -0
  41. data/lib/testcentricity_web/utility_helpers.rb +28 -0
  42. data/lib/testcentricity_web/version.rb +3 -0
  43. data/lib/testcentricity_web/webdriver_helper.rb +451 -0
  44. data/lib/testcentricity_web/world_extensions.rb +26 -0
  45. data/testcentricity_web.gemspec +42 -0
  46. metadata +52 -4
@@ -0,0 +1,84 @@
1
+ module TestCentricity
2
+ class TextField < UIElement
3
+ def initialize(name, parent, locator, context)
4
+ super
5
+ @type = :textfield
6
+ end
7
+
8
+ # Is text field set to read-only?
9
+ #
10
+ # @return [Boolean]
11
+ # @example
12
+ # comments_field.read_only?
13
+ #
14
+ def read_only?
15
+ obj, = find_element
16
+ object_not_found_exception(obj, nil)
17
+ !!obj.native.attribute('readonly')
18
+ end
19
+
20
+ # Return maxlength character count of a text field.
21
+ #
22
+ # @return [Integer]
23
+ # @example
24
+ # max_num_chars = comments_field.get_max_length
25
+ #
26
+ def get_max_length
27
+ obj, = find_element
28
+ object_not_found_exception(obj, nil)
29
+ max_length = obj.native.attribute('maxlength')
30
+ max_length.to_i unless max_length.blank?
31
+ end
32
+
33
+ # Return placeholder text of a text field.
34
+ #
35
+ # @return [String]
36
+ # @example
37
+ # placeholder_message = username_field.get_placeholder
38
+ #
39
+ def get_placeholder
40
+ obj, = find_element
41
+ object_not_found_exception(obj, nil)
42
+ obj.native.attribute('placeholder')
43
+ end
44
+
45
+ # Return min attribute of a number type text field.
46
+ #
47
+ # @return [Integer]
48
+ # @example
49
+ # min_points_value = points_field.get_min
50
+ #
51
+ def get_min
52
+ obj, = find_element
53
+ object_not_found_exception(obj, nil)
54
+ min = obj.native.attribute('min')
55
+ min.to_i unless min.blank?
56
+ end
57
+
58
+ # Return max attribute of a number type text field.
59
+ #
60
+ # @return [Integer]
61
+ # @example
62
+ # max_points_value = points_field.get_max
63
+ #
64
+ def get_max
65
+ obj, = find_element
66
+ object_not_found_exception(obj, nil)
67
+ max = obj.native.attribute('max')
68
+ max.to_i unless max.blank?
69
+ end
70
+
71
+ # Return step attribute of a number type text field.
72
+ #
73
+ # @return [Integer]
74
+ # @example
75
+ # points_step = points_field.get_step
76
+ #
77
+ def get_step
78
+ obj, = find_element
79
+ object_not_found_exception(obj, nil)
80
+ step = obj.native.attribute('step')
81
+ step.to_i unless step.blank?
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,249 @@
1
+ module TestCentricity
2
+ class EnvironData < TestCentricity::ExcelDataSource
3
+ attr_accessor :current
4
+
5
+ WKS_ENVIRONS ||= 'Environments'
6
+
7
+ def find_environ(environ_name, source_type = :excel)
8
+ case source_type
9
+ when :excel
10
+ data = ExcelData.read_row_data(XL_PRIMARY_DATA_FILE, WKS_ENVIRONS, environ_name)
11
+ when :yaml
12
+ data = read_yaml_node_data('environments.yml', environ_name)
13
+ when :json
14
+ data = read_json_node_data('environments.json', environ_name)
15
+ end
16
+ @current = Environ.new(data)
17
+ Environ.current = @current
18
+ end
19
+ end
20
+
21
+
22
+ class Environ < TestCentricity::DataObject
23
+ @session_id = Time.now.strftime('%d%H%M%S%L')
24
+ @session_time_stamp = Time.now.strftime('%Y%m%d%H%M%S')
25
+ @session_code
26
+ @test_environment = ENV['TEST_ENVIRONMENT']
27
+ @screen_shots = []
28
+
29
+ attr_accessor :test_environment
30
+ attr_accessor :browser
31
+ attr_accessor :browser_size
32
+ attr_accessor :os
33
+ attr_accessor :device
34
+ attr_accessor :device_type
35
+ attr_accessor :device_os
36
+ attr_accessor :device_orientation
37
+ attr_accessor :platform
38
+
39
+ attr_accessor :signed_in
40
+ attr_accessor :portal_status
41
+ attr_accessor :portal_context
42
+ attr_accessor :external_page
43
+
44
+ attr_accessor :protocol
45
+ attr_accessor :hostname
46
+ attr_accessor :base_url
47
+ attr_accessor :user_id
48
+ attr_accessor :password
49
+ attr_accessor :append
50
+ attr_accessor :option1
51
+ attr_accessor :option2
52
+ attr_accessor :dns
53
+ attr_accessor :db_username
54
+ attr_accessor :db_password
55
+
56
+ def initialize(data)
57
+ @protocol = data['PROTOCOL']
58
+ @hostname = data['HOST_NAME']
59
+ @base_url = data['BASE_URL']
60
+ @user_id = data['USER_ID']
61
+ @password = data['PASSWORD']
62
+ @append = data['APPEND']
63
+ @option1 = data['OPTIONAL_1']
64
+ @option2 = data['OPTIONAL_2']
65
+ @dns = data['DNS']
66
+ @db_username = data['DB_USERNAME']
67
+ @db_password = data['DB_PASSWORD']
68
+ super
69
+ end
70
+
71
+ def self.session_code
72
+ if @session_code.nil?
73
+ characters = ('a'..'z').to_a
74
+ @session_code = (0..12).map { characters.sample }.join
75
+ end
76
+ @session_code
77
+ end
78
+
79
+ def self.session_id
80
+ @session_id
81
+ end
82
+
83
+ def self.session_time_stamp
84
+ @session_time_stamp
85
+ end
86
+
87
+ def self.test_environment
88
+ if @test_environment.blank?
89
+ nil
90
+ else
91
+ @test_environment.downcase.to_sym
92
+ end
93
+ end
94
+
95
+ # @deprecated Please use {#browser=} instead
96
+ def self.set_browser(browser)
97
+ warn "[DEPRECATION] 'TestCentricity::Environ.set_browser' is deprecated. Please use 'Environ.browser =' instead."
98
+ @browser = browser.downcase.to_sym
99
+ end
100
+
101
+ def self.browser=(browser)
102
+ @browser = browser.downcase.to_sym
103
+ end
104
+
105
+ def self.browser
106
+ @browser
107
+ end
108
+
109
+ def self.browser_size=(size)
110
+ @browser_size = size
111
+ end
112
+
113
+ def self.browser_size
114
+ @browser_size
115
+ end
116
+
117
+ # @deprecated Please use {#os=} instead
118
+ def self.set_os(os)
119
+ warn "[DEPRECATION] 'TestCentricity::Environ.set_os' is deprecated. Please use 'Environ.os =' instead."
120
+ @os = os
121
+ end
122
+
123
+ def self.os=(os)
124
+ @os = os
125
+ end
126
+
127
+ def self.os
128
+ @os
129
+ end
130
+
131
+ # @deprecated Please use {#device=} instead
132
+ def self.set_device(device)
133
+ warn "[DEPRECATION] 'TestCentricity::Environ.set_device' is deprecated. Please use 'Environ.device =' instead."
134
+ @device = device
135
+ end
136
+
137
+ def self.device=(device)
138
+ @device = device
139
+ end
140
+
141
+ def self.is_device?
142
+ @device
143
+ end
144
+
145
+ # @deprecated Please use {#device_type=} instead
146
+ def self.set_device_type(type)
147
+ warn "[DEPRECATION] 'TestCentricity::Environ.set_device_type' is deprecated. Please use 'Environ.device_type =' instead."
148
+ @device_type = type.downcase
149
+ end
150
+
151
+ def self.device_type=(type)
152
+ @device_type = type.downcase
153
+ end
154
+
155
+ def self.device_type
156
+ @device_type
157
+ end
158
+
159
+ def self.device_os=(os)
160
+ @device_os = os.downcase.to_sym
161
+ end
162
+
163
+ def self.device_os
164
+ @device_os
165
+ end
166
+
167
+ def self.device_orientation=(orientation)
168
+ @device_orientation = orientation.downcase.to_sym
169
+ end
170
+
171
+ def self.device_orientation
172
+ @device_orientation
173
+ end
174
+
175
+ # @deprecated Please use {#platform=} instead
176
+ def self.set_platform(platform)
177
+ warn "[DEPRECATION] 'TestCentricity::Environ.set_platform' is deprecated. Please use 'Environ.platform =' instead."
178
+ @platform = platform
179
+ end
180
+
181
+ def self.platform=(platform)
182
+ @platform = platform
183
+ end
184
+
185
+ def self.is_mobile?
186
+ @platform == :mobile
187
+ end
188
+
189
+ def self.is_desktop?
190
+ @platform == :desktop
191
+ end
192
+
193
+ def self.set_signed_in(signed_in)
194
+ @signed_in = signed_in
195
+ end
196
+
197
+ def self.is_signed_in?
198
+ @signed_in
199
+ end
200
+
201
+ # @deprecated Please use {#portal_state=} instead
202
+ def self.set_portal_state(portal_state)
203
+ warn "[DEPRECATION] 'TestCentricity::Environ.set_portal_state' is deprecated. Please use 'Environ.portal_state =' instead."
204
+ @portal_status = portal_state
205
+ end
206
+
207
+ def self.portal_state=(portal_state)
208
+ @portal_status = portal_state
209
+ end
210
+
211
+ def self.portal_state
212
+ @portal_status
213
+ end
214
+
215
+ # @deprecated Please use {#portal_context=} instead
216
+ def self.set_portal_context(portal_context)
217
+ warn "[DEPRECATION] 'TestCentricity::Environ.set_portal_context' is deprecated. Please use 'Environ.portal_context =' instead."
218
+ @portal_context = portal_context
219
+ end
220
+
221
+ def self.portal_context=(portal_context)
222
+ @portal_context = portal_context
223
+ end
224
+
225
+ def self.portal_context
226
+ @portal_context
227
+ end
228
+
229
+ def self.set_external_page(state)
230
+ @external_page = state
231
+ end
232
+
233
+ def self.external_page
234
+ @external_page
235
+ end
236
+
237
+ def self.save_screen_shot(screen_shot)
238
+ @screen_shots.push(screen_shot)
239
+ end
240
+
241
+ def self.get_screen_shots
242
+ @screen_shots
243
+ end
244
+
245
+ def self.reset_contexts
246
+ @screen_shots = []
247
+ end
248
+ end
249
+ end
@@ -0,0 +1,242 @@
1
+ require 'time'
2
+ require 'chronic'
3
+ require 'faker'
4
+ require 'spreadsheet'
5
+
6
+
7
+ module TestCentricity
8
+ class ExcelData
9
+ @mru = {}
10
+
11
+ def self.worksheet_exists?(file, sheet)
12
+ exists = false
13
+ if File.exist?(file)
14
+ work_book = Spreadsheet.open file
15
+ worksheets = work_book.worksheets
16
+ worksheets.each do |worksheet|
17
+ if worksheet.name == sheet
18
+ exists = true
19
+ break
20
+ end
21
+ end
22
+ end
23
+ exists
24
+ end
25
+
26
+ def self.rowspec_exists?(file, sheet, rowspec)
27
+ exists = false
28
+ if worksheet_exists?(file, sheet)
29
+ work_book = Spreadsheet.open file
30
+ work_sheet = work_book.worksheet sheet
31
+ # get column headings from row 0 of worksheet
32
+ headings = work_sheet.row(0)
33
+ # if rowspec is a string then we have to find a matching row name
34
+ if rowspec.is_a? String
35
+ column_number = 0
36
+ exists = false
37
+ headings.each do |heading|
38
+ if heading == 'ROW_NAME'
39
+ exists = true
40
+ break
41
+ end
42
+ column_number += 1
43
+ end
44
+ raise "Could not find a column named ROW_NAME in worksheet #{sheet}" unless exists
45
+ # find first cell in ROW_NAME column containing a string that matches the rowspec parameter
46
+ exists = false
47
+ row_number = 0
48
+ work_sheet.each do |row|
49
+ if row[column_number] == rowspec
50
+ exists = true
51
+ break
52
+ end
53
+ row_number += 1
54
+ end
55
+ end
56
+ end
57
+ exists
58
+ end
59
+
60
+ def self.read_row_from_pool(file, sheet, rowspec, columns = nil)
61
+ raise "File #{file} does not exists" unless File.exist?(file)
62
+ work_book = Spreadsheet.open file
63
+ work_sheet = work_book.worksheet sheet
64
+
65
+ pool_spec_key = "#{sheet}:#{rowspec}"
66
+ if @mru.key?(pool_spec_key)
67
+ pool_spec = @mru[pool_spec_key]
68
+ row_start = pool_spec[:start_row]
69
+ row_end = pool_spec[:num_rows]
70
+ pool_rows = (row_start..row_start + row_end - 1).to_a
71
+ mru_rows = pool_spec[:used_rows]
72
+ new_row = pool_rows.sample.to_i
73
+ if mru_rows.size == pool_spec[:num_rows]
74
+ mru_rows = [new_row]
75
+ else
76
+ while mru_rows.include?(new_row)
77
+ new_row = pool_rows.sample.to_i
78
+ end
79
+ mru_rows.push(new_row)
80
+ mru_rows.sort!
81
+ end
82
+
83
+ pool_spec = {
84
+ :start_row => row_start,
85
+ :num_rows => row_end,
86
+ :used_rows => mru_rows
87
+ }
88
+ else
89
+ # get column headings from row 0 of worksheet
90
+ headings = work_sheet.row(0)
91
+ column_number = 0
92
+ found = false
93
+ headings.each do |heading|
94
+ if heading == 'ROW_NAME'
95
+ found = true
96
+ break
97
+ end
98
+ column_number += 1
99
+ end
100
+ raise "Could not find a column named ROW_NAME in worksheet #{sheet}" unless found
101
+ # find cell(s) in ROW_NAME column containing a string that matches the rowspec parameter
102
+ found = []
103
+ row_number = 0
104
+ work_sheet.each do |row|
105
+ if row[column_number] == rowspec
106
+ found.push(row_number)
107
+ elsif !found.empty?
108
+ break
109
+ end
110
+ row_number += 1
111
+ end
112
+ raise "Could not find a row named '#{rowspec}' in worksheet #{sheet}" if found.empty?
113
+
114
+ new_row = found.sample.to_i
115
+ pool_spec = {
116
+ :start_row => found[0],
117
+ :num_rows => found.size,
118
+ :used_rows => [new_row]
119
+ }
120
+ end
121
+ @mru[pool_spec_key] = pool_spec
122
+
123
+ read_row_data(file, sheet, new_row, columns)
124
+ end
125
+
126
+ def self.read_row_data(file, sheet, rowspec, columns = nil)
127
+ raise "File #{file} does not exists" unless File.exist?(file)
128
+ work_book = Spreadsheet.open file
129
+ work_sheet = work_book.worksheet sheet
130
+ # get column headings from row 0 of worksheet
131
+ headings = work_sheet.row(0)
132
+ # if rowspec is a string then we have to find a matching row name
133
+ if rowspec.is_a? String
134
+ column_number = 0
135
+ found = false
136
+ headings.each do |heading|
137
+ if heading == 'ROW_NAME'
138
+ found = true
139
+ break
140
+ end
141
+ column_number += 1
142
+ end
143
+ raise "Could not find a column named ROW_NAME in worksheet #{sheet}" unless found
144
+ # find first cell in ROW_NAME column containing a string that matches the rowspec parameter
145
+ found = false
146
+ row_number = 0
147
+ work_sheet.each do |row|
148
+ if row[column_number] == rowspec
149
+ found = true
150
+ break
151
+ end
152
+ row_number += 1
153
+ end
154
+ raise "Could not find a row named '#{rowspec}' in worksheet #{sheet}" unless found
155
+ data = work_sheet.row(row_number)
156
+ # if rowspec is a number then ensure that it doesn't exceed the number of available rows
157
+ elsif rowspec.is_a? Numeric
158
+ raise "Row # #{rowspec} is greater than number of rows in worksheet #{sheet}" if rowspec > work_sheet.last_row_index
159
+ data = work_sheet.row(rowspec)
160
+ end
161
+
162
+ # if no columns have been specified, return all columns
163
+ columns = headings if columns.nil?
164
+ # create results hash table
165
+ result = Hash.new
166
+ columns.each do |column|
167
+ column_number = 0
168
+ found = false
169
+ headings.each do |heading|
170
+ if column == heading
171
+ value = data[column_number].to_s
172
+ value = calculate_dynamic_value(value) if value.start_with? 'eval!'
173
+ result[column] = value
174
+ found = true
175
+ break
176
+ end
177
+ column_number += 1
178
+ end
179
+ raise "Could not find a column named '#{column}' in worksheet #{sheet}" unless found
180
+ end
181
+ result
182
+ end
183
+
184
+ def self.read_range_data(file, sheet, rangespec)
185
+ raise "File #{file} does not exists" unless File.exist?(file)
186
+ work_book = Spreadsheet.open file
187
+ work_sheet = work_book.worksheet sheet
188
+ # get column headings from row 0 of worksheet
189
+ headings = work_sheet.row(0)
190
+ column_number = 0
191
+ found = false
192
+ headings.each do |heading|
193
+ if heading == 'ROW_NAME'
194
+ found = true
195
+ break
196
+ end
197
+ column_number += 1
198
+ end
199
+ raise "Could not find a column named ROW_NAME in worksheet #{sheet}" unless found
200
+ # find cell(s) in ROW_NAME column containing a string that matches the rangespec parameter
201
+ found = []
202
+ row_number = 0
203
+ work_sheet.each do |row|
204
+ if row[column_number] == rangespec
205
+ found.push(row_number)
206
+ elsif !found.empty?
207
+ break
208
+ end
209
+ row_number += 1
210
+ end
211
+ raise "Could not find a row named '#{rangespec}' in worksheet #{sheet}" if found.empty?
212
+
213
+ result = []
214
+ found.each do |row|
215
+ result.push(read_row_data(file, sheet, row))
216
+ end
217
+ result
218
+ end
219
+
220
+ private
221
+
222
+ def self.calculate_dynamic_value(value)
223
+ test_value = value.split('!', 2)
224
+ parameter = test_value[1].split('.', 2)
225
+ case parameter[0]
226
+ when 'Date'
227
+ result = eval("Chronic.parse('#{parameter[1]}')")
228
+ when 'FormattedDate', 'FormatDate'
229
+ date_time_params = parameter[1].split(' format! ', 2)
230
+ date_time = eval("Chronic.parse('#{date_time_params[0].strip}')")
231
+ result = date_time.to_s.format_date_time("#{date_time_params[1].strip}")
232
+ else
233
+ if Faker.constants.include?(parameter[0].to_sym)
234
+ result = eval("Faker::#{parameter[0]}.#{parameter[1]}")
235
+ else
236
+ result = eval(test_value[1])
237
+ end
238
+ end
239
+ result.to_s
240
+ end
241
+ end
242
+ end