testcentricity_web 4.1.7 → 4.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.simplecov +5 -1
- data/CHANGELOG.md +12 -1
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/Rakefile +29 -3
- data/config/cucumber.yml +11 -4
- data/config/test_data/LOCAL_data.json +15 -0
- data/config/test_data/LOCAL_data.xls +0 -0
- data/config/test_data/LOCAL_data.yml +11 -0
- data/config/test_data/data.json +13 -0
- data/config/test_data/data.yml +12 -4
- data/features/basic_form_page_css.feature +39 -0
- data/features/basic_form_page_xpath.feature +26 -0
- data/features/media_players.feature +4 -7
- data/features/step_definitions/generic_steps.rb.rb +65 -0
- data/features/support/data/form_data.rb +43 -0
- data/features/support/env.rb +3 -3
- data/features/support/hooks.rb +21 -1
- data/features/support/pages/base_test_page.rb +11 -0
- data/features/support/pages/{basic_css_test_page.rb → basic_css_form_page.rb} +3 -3
- data/features/support/pages/{basic_test_page.rb → basic_form_page.rb} +120 -24
- data/features/support/pages/{basic_xpath_test_page.rb → basic_xpath_form_page.rb} +3 -3
- data/features/support/pages/custom_controls_page.rb +2 -5
- data/features/support/pages/indexed_sections_page.rb +2 -5
- data/features/support/pages/media_test_page.rb +27 -14
- data/features/support/sections/header_nav.rb +11 -0
- data/features/support/world_data.rb +1 -1
- data/features/support/world_pages.rb +2 -2
- data/lib/testcentricity_web/appium_server.rb +5 -0
- data/lib/testcentricity_web/data_objects/data_objects_helper.rb +7 -0
- data/lib/testcentricity_web/data_objects/environment.rb +2 -0
- data/lib/testcentricity_web/data_objects/excel_helper.rb +60 -59
- data/lib/testcentricity_web/version.rb +1 -1
- data/lib/testcentricity_web/web_core/drag_drop_helper.rb +4 -0
- data/lib/testcentricity_web/web_core/page_objects_helper.rb +3 -1
- data/lib/testcentricity_web/web_core/webdriver_helper.rb +16 -0
- data/lib/testcentricity_web/web_elements/file_field.rb +9 -5
- data/lib/testcentricity_web/web_elements/image.rb +2 -1
- data/lib/testcentricity_web/web_elements/media.rb +1 -13
- data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +20 -7
- data/lib/testcentricity_web/web_elements/video.rb +2 -2
- data/test_site/basic_test_page.html +1 -1
- data/test_site/media/count_and_bars.mp4 +0 -0
- data/test_site/media_page.html +2 -2
- metadata +18 -12
- data/features/basic_test_page_css.feature +0 -35
- data/features/basic_test_page_xpath.feature +0 -27
@@ -1,8 +1,9 @@
|
|
1
|
-
# Page Object class definition for Basic HTML
|
1
|
+
# Page Object class definition for Basic HTML Form page
|
2
2
|
|
3
|
-
class
|
3
|
+
class BasicFormPage < BaseTestPage
|
4
4
|
trait(:page_url) { '/basic_test_page.html' }
|
5
5
|
trait(:navigator) { header_nav.open_form_page }
|
6
|
+
trait(:page_title) { 'Basic HTML Form'}
|
6
7
|
trait(:tab_order) {
|
7
8
|
[
|
8
9
|
header_nav.form_link,
|
@@ -73,17 +74,44 @@ class BasicTestPage < BaseTestPage
|
|
73
74
|
}
|
74
75
|
|
75
76
|
def verify_page_ui
|
77
|
+
super
|
78
|
+
|
79
|
+
verify_page_contains(page_title)
|
80
|
+
image_1.wait_until_loaded(5)
|
81
|
+
username_field.scroll_to(:center) if username_field.obscured?
|
76
82
|
ui = {
|
77
|
-
self => { exists: true, secure: false, title: 'Basic HTML Form' },
|
78
|
-
header_label => { visible: true, caption: 'Basic HTML Form Example' },
|
79
83
|
username_label => { visible: true, caption: 'Username:' },
|
80
|
-
username_field => {
|
84
|
+
username_field => {
|
85
|
+
name: 'username',
|
86
|
+
exists: true,
|
87
|
+
displayed: true,
|
88
|
+
obscured: false,
|
89
|
+
visible: true,
|
90
|
+
hidden: false,
|
91
|
+
enabled: true,
|
92
|
+
disabled: false,
|
93
|
+
required: true,
|
94
|
+
value: '',
|
95
|
+
placeholder: 'User name'
|
96
|
+
},
|
81
97
|
password_label => { visible: true, caption: 'Password:' },
|
82
|
-
password_field => {
|
98
|
+
password_field => {
|
99
|
+
name: 'password',
|
100
|
+
visible: true,
|
101
|
+
displayed: true,
|
102
|
+
obscured: false,
|
103
|
+
focused: false,
|
104
|
+
enabled: true,
|
105
|
+
required: true,
|
106
|
+
value: '',
|
107
|
+
placeholder: 'Password'
|
108
|
+
},
|
83
109
|
max_length_label => { visible: true, caption: 'Max Length:' },
|
84
110
|
max_length_field => {
|
85
111
|
visible: true,
|
112
|
+
obscured: false,
|
86
113
|
enabled: true,
|
114
|
+
focused: false,
|
87
115
|
placeholder: 'up to 64 characters',
|
88
116
|
value: '',
|
89
117
|
maxlength: 64
|
@@ -119,15 +147,75 @@ class BasicTestPage < BaseTestPage
|
|
119
147
|
filename_label => { visible: true, caption: 'Filename:' },
|
120
148
|
upload_file => { visible: true, enabled: true, value: '' },
|
121
149
|
checkboxes_label => { visible: true, caption: 'Checkbox Items:' },
|
122
|
-
check_1 => {
|
123
|
-
|
124
|
-
|
125
|
-
|
150
|
+
check_1 => {
|
151
|
+
exists: true,
|
152
|
+
visible: true,
|
153
|
+
hidden: false,
|
154
|
+
enabled: true,
|
155
|
+
disabled: false,
|
156
|
+
checked: false,
|
157
|
+
indeterminate: false
|
158
|
+
},
|
159
|
+
check_2 => {
|
160
|
+
exists: true,
|
161
|
+
visible: true,
|
162
|
+
hidden: false,
|
163
|
+
enabled: true,
|
164
|
+
disabled: false,
|
165
|
+
checked: false,
|
166
|
+
indeterminate: false
|
167
|
+
},
|
168
|
+
check_3 => {
|
169
|
+
exists: true,
|
170
|
+
visible: true,
|
171
|
+
hidden: false,
|
172
|
+
enabled: true,
|
173
|
+
disabled: false,
|
174
|
+
checked: false,
|
175
|
+
indeterminate: false
|
176
|
+
},
|
177
|
+
check_4 => {
|
178
|
+
exists: true,
|
179
|
+
visible: true,
|
180
|
+
hidden: false,
|
181
|
+
enabled: false,
|
182
|
+
disabled: true,
|
183
|
+
checked: false,
|
184
|
+
indeterminate: false
|
185
|
+
},
|
126
186
|
radios_label => { visible: true, caption: 'Radio Items:' },
|
127
|
-
radio_1 => {
|
128
|
-
|
129
|
-
|
130
|
-
|
187
|
+
radio_1 => {
|
188
|
+
exists: true,
|
189
|
+
visible: true,
|
190
|
+
hidden: false,
|
191
|
+
enabled: true,
|
192
|
+
disabled: false,
|
193
|
+
selected: false
|
194
|
+
},
|
195
|
+
radio_2 => {
|
196
|
+
exists: true,
|
197
|
+
visible: true,
|
198
|
+
hidden: false,
|
199
|
+
enabled: true,
|
200
|
+
disabled: false,
|
201
|
+
selected: false
|
202
|
+
},
|
203
|
+
radio_3 => {
|
204
|
+
exists: true,
|
205
|
+
visible: true,
|
206
|
+
hidden: false,
|
207
|
+
enabled: true,
|
208
|
+
disabled: false,
|
209
|
+
selected: false
|
210
|
+
},
|
211
|
+
radio_4 => {
|
212
|
+
exists: true,
|
213
|
+
visible: true,
|
214
|
+
hidden: false,
|
215
|
+
enabled: false,
|
216
|
+
disabled: true,
|
217
|
+
selected: false
|
218
|
+
},
|
131
219
|
multiselect_label => { visible: true, caption: 'Multiple Select Values:' },
|
132
220
|
multi_select => {
|
133
221
|
visible: true,
|
@@ -158,6 +246,7 @@ class BasicTestPage < BaseTestPage
|
|
158
246
|
link_3 => {
|
159
247
|
visible: true,
|
160
248
|
aria_disabled: true,
|
249
|
+
role: 'link',
|
161
250
|
caption: 'Disabled Link'
|
162
251
|
},
|
163
252
|
table_label => { visible: true, caption: 'Table:' },
|
@@ -169,17 +258,22 @@ class BasicTestPage < BaseTestPage
|
|
169
258
|
{ row: 1 } => [['Alfreds Futterkiste', 'Maria Anders', 'Germany']],
|
170
259
|
{ row: 2 } => [['Centro comercial Moctezuma', 'Francisco Chang', 'Mexico']],
|
171
260
|
{ row: 3 } => [['Ernst Handel', 'Roland Mendel', 'Austria']],
|
172
|
-
{ row: 4 } => [['Island Trading', 'Helen Bennett', 'UK']]
|
261
|
+
{ row: 4 } => [['Island Trading', 'Helen Bennett', 'UK']],
|
262
|
+
{ cell: [1, 3] } => ['Germany'],
|
263
|
+
{ cell: [2, 3] } => ['Mexico'],
|
264
|
+
{ column: 3 } => [['Germany', 'Mexico', 'Austria', 'UK']]
|
173
265
|
},
|
174
266
|
images_label => { visible: true, caption: 'Images:' },
|
175
267
|
image_1 => {
|
176
268
|
visible: true,
|
269
|
+
loaded: true,
|
177
270
|
broken: false,
|
178
271
|
src: { ends_with: 'images/Wilder.jpg' },
|
179
272
|
alt: "It's alive"
|
180
273
|
},
|
181
274
|
image_2 => {
|
182
275
|
visible: true,
|
276
|
+
loaded: true,
|
183
277
|
broken: false,
|
184
278
|
src: { ends_with: 'images/You_Betcha.jpg' },
|
185
279
|
alt: 'You Betcha'
|
@@ -197,18 +291,20 @@ class BasicTestPage < BaseTestPage
|
|
197
291
|
end
|
198
292
|
|
199
293
|
def form_data
|
294
|
+
data = form_data_source.read_form_data
|
295
|
+
|
200
296
|
if Environ.platform == :mobile
|
201
297
|
file_path = nil
|
202
298
|
file_name = ''
|
203
299
|
color_value = '#000000'
|
204
300
|
else
|
205
|
-
file_path = "#{Dir.pwd}/test_site/images
|
206
|
-
file_name =
|
301
|
+
file_path = "#{Dir.pwd}/test_site/images/#{data.image_filename}"
|
302
|
+
file_name = data.image_filename
|
207
303
|
color_value = Faker::Color.hex_color
|
208
304
|
end
|
209
305
|
{
|
210
|
-
username:
|
211
|
-
password:
|
306
|
+
username: data.username,
|
307
|
+
password: data.password,
|
212
308
|
maxlength: Faker::Marketing.buzzwords,
|
213
309
|
number: Faker::Number.between(from: 10, to: 1024),
|
214
310
|
color: color_value,
|
@@ -216,14 +312,14 @@ class BasicTestPage < BaseTestPage
|
|
216
312
|
comments: Faker::Hipster.paragraph,
|
217
313
|
filepath: file_path,
|
218
314
|
filename: file_name,
|
219
|
-
check1:
|
220
|
-
check2:
|
221
|
-
check3:
|
315
|
+
check1: data.check1,
|
316
|
+
check2: data.check2,
|
317
|
+
check3: data.check3,
|
222
318
|
radio1: false,
|
223
319
|
radio2: true,
|
224
320
|
radio3: false,
|
225
|
-
multi_select:
|
226
|
-
drop_select:
|
321
|
+
multi_select: data.multi_select,
|
322
|
+
drop_select: data.drop_down_item
|
227
323
|
}
|
228
324
|
end
|
229
325
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
# Page Object class definition for Basic HTML
|
1
|
+
# Page Object class definition for Basic HTML Form page with Xpath locators
|
2
2
|
|
3
|
-
class
|
4
|
-
trait(:page_name) { 'Basic Xpath
|
3
|
+
class BasicXpathFormPage < BasicFormPage
|
4
|
+
trait(:page_name) { 'Basic Xpath Form' }
|
5
5
|
trait(:page_locator) { "//form[@id='HTMLFormElements']" }
|
6
6
|
|
7
7
|
# Basic HTML Test page UI elements
|
@@ -5,12 +5,9 @@ class CustomControlsPage < BaseTestPage
|
|
5
5
|
trait(:page_locator) { 'div.custom-controls-page-body' }
|
6
6
|
trait(:page_url) { '/custom_controls_page.html' }
|
7
7
|
trait(:navigator) { header_nav.open_custom_controls_page }
|
8
|
+
trait(:page_title) { 'Custom Controls Page'}
|
8
9
|
|
9
10
|
def verify_page_ui
|
10
|
-
|
11
|
-
self => { exists: true, secure: false, title: 'Custom Controls Page' },
|
12
|
-
header_label => { visible: true, caption: 'Custom Controls Page' }
|
13
|
-
}
|
14
|
-
verify_ui_states(ui)
|
11
|
+
super
|
15
12
|
end
|
16
13
|
end
|
@@ -5,12 +5,9 @@ class IndexedSectionsPage < BaseTestPage
|
|
5
5
|
trait(:page_locator) { 'div.indexed-sections-page-body' }
|
6
6
|
trait(:page_url) { '/indexed_sections_page.html' }
|
7
7
|
trait(:navigator) { header_nav.open_indexed_sections_page }
|
8
|
+
trait(:page_title) { 'Indexed Sections Page'}
|
8
9
|
|
9
10
|
def verify_page_ui
|
10
|
-
|
11
|
-
self => { exists: true, secure: false, title: 'Indexed Sections Page' },
|
12
|
-
header_label => { visible: true, caption: 'Indexed Sections Page' }
|
13
|
-
}
|
14
|
-
verify_ui_states(ui)
|
11
|
+
super
|
15
12
|
end
|
16
13
|
end
|
@@ -5,25 +5,29 @@ class MediaTestPage < BaseTestPage
|
|
5
5
|
trait(:page_locator) { 'div.media-page-body' }
|
6
6
|
trait(:page_url) { '/media_page.html' }
|
7
7
|
trait(:navigator) { header_nav.open_media_page }
|
8
|
+
trait(:page_title) { 'Media Page'}
|
8
9
|
|
9
10
|
# Media Test page UI elements
|
10
|
-
videos
|
11
|
+
videos video_player_1: 'video#video_player1'
|
11
12
|
audios audio_player: 'audio#audio_player'
|
12
13
|
|
13
14
|
def verify_page_ui
|
15
|
+
super
|
16
|
+
|
14
17
|
preload = case
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
when Environ.browser == :safari
|
19
|
+
'auto'
|
20
|
+
when Environ.device_os == :ios && Environ.driver != :webdriver
|
21
|
+
'auto'
|
22
|
+
when %i[firefox firefox_headless].include?(Environ.browser)
|
23
|
+
''
|
24
|
+
else
|
25
|
+
'metadata'
|
26
|
+
end
|
27
|
+
video_player_1.wait_until_ready_state_is(4, 10)
|
28
|
+
audio_player.wait_until_ready_state_is(4, 10)
|
23
29
|
ui = {
|
24
|
-
|
25
|
-
header_label => { visible: true, caption: 'Media Page' },
|
26
|
-
video_player => {
|
30
|
+
video_player_1 => {
|
27
31
|
visible: true,
|
28
32
|
paused: true,
|
29
33
|
autoplay: false,
|
@@ -64,6 +68,14 @@ class MediaTestPage < BaseTestPage
|
|
64
68
|
}
|
65
69
|
}
|
66
70
|
verify_ui_states(ui)
|
71
|
+
unless Environ.browser == :safari
|
72
|
+
ui = { video_player_1 => {
|
73
|
+
width: video_player_1.video_width,
|
74
|
+
height: video_player_1.video_height
|
75
|
+
}
|
76
|
+
}
|
77
|
+
verify_ui_states(ui)
|
78
|
+
end
|
67
79
|
end
|
68
80
|
|
69
81
|
def perform_action(media_type, action)
|
@@ -72,7 +84,7 @@ class MediaTestPage < BaseTestPage
|
|
72
84
|
when :play
|
73
85
|
player.play
|
74
86
|
player.send_keys(:enter) if player.paused?
|
75
|
-
player.
|
87
|
+
player.click_at(25, 25) if player.paused?
|
76
88
|
when :pause
|
77
89
|
player.pause
|
78
90
|
when :mute
|
@@ -175,7 +187,7 @@ class MediaTestPage < BaseTestPage
|
|
175
187
|
def dispatch_player(media_type)
|
176
188
|
player = case media_type.downcase.to_sym
|
177
189
|
when :video
|
178
|
-
|
190
|
+
video_player_1
|
179
191
|
when :audio
|
180
192
|
audio_player
|
181
193
|
else
|
@@ -190,6 +202,7 @@ class MediaTestPage < BaseTestPage
|
|
190
202
|
player.current_time = 0
|
191
203
|
player.play
|
192
204
|
player.send_keys(:enter) if player.paused?
|
205
|
+
player.click_at(25, 25) if player.paused?
|
193
206
|
sleep(1)
|
194
207
|
end
|
195
208
|
end
|
@@ -25,4 +25,15 @@ class NavHeader < TestCentricity::PageSection
|
|
25
25
|
def open_custom_controls_page
|
26
26
|
custom_controls_link.click
|
27
27
|
end
|
28
|
+
|
29
|
+
def verify_nav_bar
|
30
|
+
ui = {
|
31
|
+
self => { exists: true, visible: true, class: 'topnav' },
|
32
|
+
form_link => { visible: true, caption: 'Basic HTML Form' },
|
33
|
+
media_link => { visible: true, caption: 'Media' },
|
34
|
+
indexed_sections_link => { visible: true, caption: 'Indexed Sections' },
|
35
|
+
custom_controls_link => { visible: true, caption: 'Custom Controls' },
|
36
|
+
}
|
37
|
+
verify_ui_states(ui)
|
38
|
+
end
|
28
39
|
end
|
@@ -5,8 +5,8 @@ module WorldPages
|
|
5
5
|
#
|
6
6
|
def page_objects
|
7
7
|
{
|
8
|
-
|
9
|
-
|
8
|
+
basic_css_form_page: BasicCSSFormPage,
|
9
|
+
basic_xpath_form_page: BasicXpathFormPage,
|
10
10
|
media_test_page: MediaTestPage,
|
11
11
|
indexed_sections_page: IndexedSectionsPage,
|
12
12
|
custom_controls_page: CustomControlsPage
|
@@ -18,10 +18,12 @@ module TestCentricity
|
|
18
18
|
def start
|
19
19
|
# terminate any currently running Appium Server
|
20
20
|
if running?
|
21
|
+
# :nocov:
|
21
22
|
system('killall -9 node')
|
22
23
|
puts 'Terminating existing Appium Server'
|
23
24
|
sleep(5)
|
24
25
|
puts 'Appium Server is being restarted'
|
26
|
+
# :nocov:
|
25
27
|
else
|
26
28
|
puts 'Appium Server is starting'
|
27
29
|
end
|
@@ -56,6 +58,7 @@ module TestCentricity
|
|
56
58
|
|
57
59
|
private
|
58
60
|
|
61
|
+
# :nocov:
|
59
62
|
def parameters
|
60
63
|
cmd = ['appium']
|
61
64
|
@params.each do |key, value|
|
@@ -64,5 +67,7 @@ module TestCentricity
|
|
64
67
|
end
|
65
68
|
cmd
|
66
69
|
end
|
70
|
+
# :nocov:
|
67
71
|
end
|
68
72
|
end
|
73
|
+
|
@@ -52,6 +52,7 @@ module TestCentricity
|
|
52
52
|
@current = current
|
53
53
|
end
|
54
54
|
|
55
|
+
# :nocov:
|
55
56
|
def to_hash(node_name = nil)
|
56
57
|
data = {}
|
57
58
|
if node_name.nil?
|
@@ -79,9 +80,12 @@ module TestCentricity
|
|
79
80
|
def write_json_data(file_name, mode, node_name = nil)
|
80
81
|
File.open(file_name, mode) { |file| file.write(to_json(node_name)) }
|
81
82
|
end
|
83
|
+
|
84
|
+
# :nocov:
|
82
85
|
end
|
83
86
|
|
84
87
|
|
88
|
+
# :nocov:
|
85
89
|
class DataSource
|
86
90
|
attr_accessor :file_path
|
87
91
|
attr_accessor :node
|
@@ -135,6 +139,7 @@ module TestCentricity
|
|
135
139
|
result.to_s
|
136
140
|
end
|
137
141
|
end
|
142
|
+
# :nocov:
|
138
143
|
|
139
144
|
|
140
145
|
class ExcelDataSource < TestCentricity::DataSource
|
@@ -159,6 +164,7 @@ module TestCentricity
|
|
159
164
|
ExcelData.read_row_data(pick_excel_data_source(sheet, @row_spec), sheet, @row_spec)
|
160
165
|
end
|
161
166
|
|
167
|
+
# :nocov:
|
162
168
|
def read_excel_pool_data(sheet, row_name, parallel = false)
|
163
169
|
@row_spec = parallel == :parallel && ENV['PARALLEL'] ? "#{row_name}#{ENV['TEST_ENV_NUMBER']}" : row_name
|
164
170
|
ExcelData.read_row_from_pool(pick_excel_data_source(sheet, row_name), sheet, @row_spec)
|
@@ -173,6 +179,7 @@ module TestCentricity
|
|
173
179
|
@row_spec = parallel == :parallel && ENV['PARALLEL'] ? "#{row_name}#{ENV['TEST_ENV_NUMBER']}" : row_name
|
174
180
|
ExcelData.write_row_data(pick_excel_data_source(sheet, @row_spec), sheet, @row_spec, row_data)
|
175
181
|
end
|
182
|
+
# :nocov:
|
176
183
|
end
|
177
184
|
end
|
178
185
|
|
@@ -396,6 +396,7 @@ module TestCentricity
|
|
396
396
|
@screen_shots = []
|
397
397
|
end
|
398
398
|
|
399
|
+
# :nocov:
|
399
400
|
def self.report_header
|
400
401
|
report_header = "\n<b><u>TEST ENVIRONMENT</u>:</b> #{ENV['TEST_ENVIRONMENT']}\n"\
|
401
402
|
" <b>Browser:</b>\t #{Environ.browser.capitalize}\n"
|
@@ -411,6 +412,7 @@ module TestCentricity
|
|
411
412
|
report_header = "#{report_header} <b>WCAG Accessibility Standard:</b>\t #{ENV['ACCESSIBILITY_STANDARD']}\n" if ENV['ACCESSIBILITY_STANDARD']
|
412
413
|
"#{report_header}\n\n"
|
413
414
|
end
|
415
|
+
# :nocov:
|
414
416
|
end
|
415
417
|
end
|
416
418
|
|
@@ -52,6 +52,65 @@ module TestCentricity
|
|
52
52
|
exists
|
53
53
|
end
|
54
54
|
|
55
|
+
def self.read_row_data(file, sheet, row_spec, columns = nil)
|
56
|
+
raise "File #{file} does not exists" unless File.exist?(file)
|
57
|
+
work_book = Spreadsheet.open(file)
|
58
|
+
work_sheet = work_book.worksheet(sheet)
|
59
|
+
# get column headings from row 0 of worksheet
|
60
|
+
headings = work_sheet.row(0)
|
61
|
+
# if row_spec is a string then we have to find a matching row name
|
62
|
+
if row_spec.is_a? String
|
63
|
+
column_number = 0
|
64
|
+
found = false
|
65
|
+
headings.each do |heading|
|
66
|
+
if heading == 'ROW_NAME'
|
67
|
+
found = true
|
68
|
+
break
|
69
|
+
end
|
70
|
+
column_number += 1
|
71
|
+
end
|
72
|
+
raise "Could not find a column named ROW_NAME in worksheet #{sheet}" unless found
|
73
|
+
# find first cell in ROW_NAME column containing a string that matches the row_spec parameter
|
74
|
+
found = false
|
75
|
+
row_number = 0
|
76
|
+
work_sheet.each do |row|
|
77
|
+
if row[column_number] == row_spec
|
78
|
+
found = true
|
79
|
+
break
|
80
|
+
end
|
81
|
+
row_number += 1
|
82
|
+
end
|
83
|
+
raise "Could not find a row named '#{row_spec}' in worksheet #{sheet}" unless found
|
84
|
+
data = work_sheet.row(row_number)
|
85
|
+
# if row_spec is a number then ensure that it doesn't exceed the number of available rows
|
86
|
+
elsif row_spec.is_a? Numeric
|
87
|
+
raise "Row # #{row_spec} is greater than number of rows in worksheet #{sheet}" if row_spec > work_sheet.last_row_index
|
88
|
+
data = work_sheet.row(row_spec)
|
89
|
+
end
|
90
|
+
|
91
|
+
# if no columns have been specified, return all columns
|
92
|
+
columns = headings if columns.nil?
|
93
|
+
# create results hash table
|
94
|
+
result = Hash.new
|
95
|
+
columns.each do |column|
|
96
|
+
column_number = 0
|
97
|
+
found = false
|
98
|
+
headings.each do |heading|
|
99
|
+
if column == heading
|
100
|
+
value = data[column_number].to_s
|
101
|
+
value = calculate_dynamic_value(value) if value.start_with? 'eval!'
|
102
|
+
result[column] = value
|
103
|
+
found = true
|
104
|
+
break
|
105
|
+
end
|
106
|
+
column_number += 1
|
107
|
+
end
|
108
|
+
raise "Could not find a column named '#{column}' in worksheet #{sheet}" unless found
|
109
|
+
end
|
110
|
+
result
|
111
|
+
end
|
112
|
+
|
113
|
+
# :nocov:
|
55
114
|
def self.read_row_from_pool(file, sheet, row_spec, columns = nil)
|
56
115
|
raise "File #{file} does not exists" unless File.exist?(file)
|
57
116
|
work_book = Spreadsheet.open(file)
|
@@ -118,64 +177,6 @@ module TestCentricity
|
|
118
177
|
read_row_data(file, sheet, new_row, columns)
|
119
178
|
end
|
120
179
|
|
121
|
-
def self.read_row_data(file, sheet, row_spec, columns = nil)
|
122
|
-
raise "File #{file} does not exists" unless File.exist?(file)
|
123
|
-
work_book = Spreadsheet.open(file)
|
124
|
-
work_sheet = work_book.worksheet(sheet)
|
125
|
-
# get column headings from row 0 of worksheet
|
126
|
-
headings = work_sheet.row(0)
|
127
|
-
# if row_spec is a string then we have to find a matching row name
|
128
|
-
if row_spec.is_a? String
|
129
|
-
column_number = 0
|
130
|
-
found = false
|
131
|
-
headings.each do |heading|
|
132
|
-
if heading == 'ROW_NAME'
|
133
|
-
found = true
|
134
|
-
break
|
135
|
-
end
|
136
|
-
column_number += 1
|
137
|
-
end
|
138
|
-
raise "Could not find a column named ROW_NAME in worksheet #{sheet}" unless found
|
139
|
-
# find first cell in ROW_NAME column containing a string that matches the row_spec parameter
|
140
|
-
found = false
|
141
|
-
row_number = 0
|
142
|
-
work_sheet.each do |row|
|
143
|
-
if row[column_number] == row_spec
|
144
|
-
found = true
|
145
|
-
break
|
146
|
-
end
|
147
|
-
row_number += 1
|
148
|
-
end
|
149
|
-
raise "Could not find a row named '#{row_spec}' in worksheet #{sheet}" unless found
|
150
|
-
data = work_sheet.row(row_number)
|
151
|
-
# if row_spec is a number then ensure that it doesn't exceed the number of available rows
|
152
|
-
elsif row_spec.is_a? Numeric
|
153
|
-
raise "Row # #{row_spec} is greater than number of rows in worksheet #{sheet}" if row_spec > work_sheet.last_row_index
|
154
|
-
data = work_sheet.row(row_spec)
|
155
|
-
end
|
156
|
-
|
157
|
-
# if no columns have been specified, return all columns
|
158
|
-
columns = headings if columns.nil?
|
159
|
-
# create results hash table
|
160
|
-
result = Hash.new
|
161
|
-
columns.each do |column|
|
162
|
-
column_number = 0
|
163
|
-
found = false
|
164
|
-
headings.each do |heading|
|
165
|
-
if column == heading
|
166
|
-
value = data[column_number].to_s
|
167
|
-
value = calculate_dynamic_value(value) if value.start_with? 'eval!'
|
168
|
-
result[column] = value
|
169
|
-
found = true
|
170
|
-
break
|
171
|
-
end
|
172
|
-
column_number += 1
|
173
|
-
end
|
174
|
-
raise "Could not find a column named '#{column}' in worksheet #{sheet}" unless found
|
175
|
-
end
|
176
|
-
result
|
177
|
-
end
|
178
|
-
|
179
180
|
def self.read_range_data(file, sheet, range_spec)
|
180
181
|
raise "File #{file} does not exists" unless File.exist?(file)
|
181
182
|
work_book = Spreadsheet.open(file)
|
@@ -270,6 +271,6 @@ module TestCentricity
|
|
270
271
|
# rename new Excel document, replacing the original
|
271
272
|
File.rename(outfile, file)
|
272
273
|
end
|
274
|
+
# :nocov:
|
273
275
|
end
|
274
276
|
end
|
275
|
-
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# :nocov:
|
2
|
+
|
1
3
|
module CapybaraExtension
|
2
4
|
def drag_by(right_by, down_by)
|
3
5
|
base.drag_by(right_by, down_by)
|
@@ -11,5 +13,7 @@ module CapybaraSeleniumExtension
|
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
16
|
+
# :nocov:
|
17
|
+
|
14
18
|
::Capybara::Selenium::Node.send :include, CapybaraSeleniumExtension
|
15
19
|
::Capybara::Node::Element.send :include, CapybaraExtension
|
@@ -65,6 +65,8 @@ module TestCentricity
|
|
65
65
|
ui_object.hidden?
|
66
66
|
when :displayed
|
67
67
|
ui_object.displayed?
|
68
|
+
when :obscured
|
69
|
+
ui_object.obscured?
|
68
70
|
when :focused
|
69
71
|
ui_object.focused?
|
70
72
|
when :width
|
@@ -312,7 +314,7 @@ module TestCentricity
|
|
312
314
|
check_state = data_param.is_a?(String) ? data_param.to_bool : data_param
|
313
315
|
data_field.set_selected_state(check_state)
|
314
316
|
when :textfield
|
315
|
-
if data_field.get_attribute(:type)
|
317
|
+
if %w[color number].include?(data_field.get_attribute(:type))
|
316
318
|
data_field.set(data_param)
|
317
319
|
else
|
318
320
|
data_field.set("#{data_param}\t")
|