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,612 +0,0 @@
1
- module TestCentricity
2
- class Table < UIElement
3
- attr_accessor :table_body
4
- attr_accessor :table_section
5
- attr_accessor :table_row
6
- attr_accessor :table_column
7
- attr_accessor :table_header
8
- attr_accessor :header_row
9
- attr_accessor :header_column
10
- attr_accessor :tree_expand
11
- attr_accessor :tree_collapse
12
-
13
- def initialize(name, parent, locator, context)
14
- super
15
- @type = :table
16
-
17
- table_spec = { :table_body => 'tbody',
18
- :table_section => nil,
19
- :table_row => 'tr',
20
- :table_column => 'td',
21
- :table_header => 'thead',
22
- :header_row => 'tr',
23
- :header_column => 'th' }
24
-
25
- case @locator_type
26
- when :xpath
27
- table_spec[:tree_expand] = "div/div[contains(@class, 'tree-plus treeclick')]"
28
- table_spec[:tree_collapse] = "div/div[contains(@class, 'tree-minus treeclick')]"
29
- when :css
30
- table_spec[:tree_expand] = "div/div[class*='tree-plus treeclick']"
31
- table_spec[:tree_collapse] = "div/div[class*='tree-minus treeclick']"
32
- end
33
- define_table_elements(table_spec)
34
- end
35
-
36
- def define_table_elements(element_spec)
37
- element_spec.each do |element, value|
38
- case element
39
- when :table_body
40
- @table_body = value
41
- when :table_section
42
- @table_section = value
43
- when :table_row
44
- @table_row = value
45
- when :table_column
46
- @table_column = value
47
- when :table_header
48
- @table_header = value
49
- when :header_row
50
- @header_row = value
51
- when :header_column
52
- @header_column = value
53
- when :tree_expand
54
- @tree_expand = value
55
- when :tree_collapse
56
- @tree_collapse = value
57
- else
58
- raise "#{element} is not a recognized table element"
59
- end
60
- end
61
- end
62
-
63
- # Return number of rows in a table object.
64
- #
65
- # @return [Integer]
66
- # @example
67
- # num_rows = list_table.get_row_count
68
- #
69
- def get_row_count
70
- wait_until_exists(5)
71
- case @locator_type
72
- when :xpath
73
- if @table_section.nil?
74
- page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_row}", :visible => :all).count
75
- else
76
- page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_section}", :visible => :all).count
77
- end
78
- when :css
79
- if @table_section.nil?
80
- page.all(:css, "#{@locator} > #{@table_body} > #{@table_row}", :visible => :all).count
81
- else
82
- page.all(:css, "#{@locator} > #{@table_body} > #{@table_section}", :visible => :all).count
83
- end
84
- end
85
- end
86
-
87
- # Return number of columns in a table object.
88
- #
89
- # @return [Integer]
90
- # @example
91
- # num_columns = list_table.get_column_count
92
- #
93
- def get_column_count
94
- row_count = get_row_count
95
- case @locator_type
96
- when :xpath
97
- if row_count == 0
98
- page.all(:xpath, "#{@locator}/#{@table_header}/#{@header_row}/#{@header_column}", :visible => :all).count
99
- else
100
- if @table_section.nil?
101
- row_count == 1 ?
102
- page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_row}/#{@table_column}", :visible => :all).count :
103
- page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_row}[2]/#{@table_column}", :visible => :all).count
104
- else
105
- row_count == 1 ?
106
- page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_section}/#{@table_row}/#{@table_column}", :visible => :all).count :
107
- page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_section}[2]/#{@table_row}/#{@table_column}", :visible => :all).count
108
- end
109
- end
110
- when :css
111
- if row_count == 0
112
- page.all(:css, "#{@locator} > #{@table_header} > #{@header_row} > #{@header_column}", :visible => :all).count
113
- else
114
- if @table_section.nil?
115
- row_count == 1 ?
116
- page.all(:css, "#{@locator} > #{@table_body} > #{@table_row} > #{@table_column}", :visible => :all).count :
117
- page.all(:css, "#{@locator} > #{@table_body} > #{@table_row}:nth-of-type(2) > #{@table_column}", :visible => :all).count
118
- else
119
- row_count == 1 ?
120
- page.all(:css, "#{@locator} > #{@table_body} > #{@table_section} > #{@table_row} > #{@table_column}", :visible => :all).count :
121
- page.all(:css, "#{@locator} > #{@table_body} > #{@table_section}:nth-of-type(2) > #{@table_row} > #{@table_column}", :visible => :all).count
122
- end
123
- end
124
- end
125
- end
126
-
127
- # Hover over the specified cell in a table object.
128
- #
129
- # @param row [Integer] row number
130
- # @param column [Integer] column number
131
- # @example
132
- # list_table.hover_table_cell(2, 6)
133
- #
134
- def hover_table_cell(row, column)
135
- row_count = get_row_count
136
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
137
- column_count = get_column_count
138
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
139
- set_table_cell_locator(row, column)
140
- hover
141
- clear_alt_locator
142
- end
143
-
144
- # Click in the specified cell in a table object.
145
- #
146
- # @param row [Integer] row number
147
- # @param column [Integer] column number
148
- # @example
149
- # list_table.click_table_cell(3, 5)
150
- #
151
- def click_table_cell(row, column)
152
- row_count = get_row_count
153
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
154
- column_count = get_column_count
155
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
156
- set_table_cell_locator(row, column)
157
- click
158
- clear_alt_locator
159
- end
160
-
161
- # Double-click in the specified cell in a table object.
162
- #
163
- # @param row [Integer] row number
164
- # @param column [Integer] column number
165
- # @example
166
- # list_table.double_click_table_cell(3, 5)
167
- #
168
- def double_click_table_cell(row, column)
169
- row_count = get_row_count
170
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
171
- column_count = get_column_count
172
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
173
- set_table_cell_locator(row, column)
174
- double_click
175
- clear_alt_locator
176
- end
177
-
178
- # Click the link object embedded within the specified cell in a table object.
179
- #
180
- # @param row [Integer] row number
181
- # @param column [Integer] column number
182
- # @example
183
- # list_table.click_table_cell_link(3, 1)
184
- #
185
- def click_table_cell_link(row, column)
186
- row_count = get_row_count
187
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
188
- column_count = get_column_count
189
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
190
- set_table_cell_locator(row, column)
191
- saved_locator = @alt_locator
192
- case @locator_type
193
- when :xpath
194
- set_alt_locator("#{@alt_locator}//a")
195
- set_alt_locator("#{saved_locator}//span/a") unless exists?
196
- # if link not present, check for text entry fields and try to dismiss by tabbing out
197
- unless exists?
198
- set_alt_locator("#{saved_locator}//input")
199
- set_alt_locator("#{saved_locator}//textarea") unless exists?
200
- send_keys(:tab) if exists?
201
- set_alt_locator("#{saved_locator}//a")
202
- set_alt_locator("#{saved_locator}//span/a") unless exists?
203
- send_keys(:tab) unless exists?
204
- end
205
- when :css
206
- set_alt_locator("#{@alt_locator} a")
207
- set_alt_locator("#{saved_locator} span > a") unless exists?
208
- # if link not present, check for text entry fields and try to dismiss by tabbing out
209
- unless exists?
210
- set_alt_locator("#{saved_locator} input")
211
- set_alt_locator("#{saved_locator} textarea") unless exists?
212
- send_keys(:tab) if exists?
213
- set_alt_locator("#{saved_locator} a")
214
- set_alt_locator("#{saved_locator} span > a") unless exists?
215
- send_keys(:tab) unless exists?
216
- end
217
- end
218
- wait_until_exists(1)
219
- click
220
- clear_alt_locator
221
- end
222
-
223
- def get_table_row(row)
224
- columns = []
225
- row_count = get_row_count
226
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
227
- column_count = get_column_count
228
- (1..column_count).each do |column|
229
- value = ''
230
- set_table_cell_locator(row, column)
231
- saved_locator = @alt_locator
232
- case @locator_type
233
- when :xpath
234
- set_alt_locator("#{saved_locator}//input")
235
- unless exists?
236
- set_alt_locator("#{saved_locator}//textarea")
237
- set_alt_locator(saved_locator) unless exists?
238
- end
239
- when :css
240
- set_alt_locator("#{saved_locator} input")
241
- unless exists?
242
- set_alt_locator("#{saved_locator} textarea")
243
- set_alt_locator(saved_locator) unless exists?
244
- end
245
- end
246
- value = get_value if exists?
247
- columns.push(value)
248
- end
249
- clear_alt_locator
250
- columns
251
- end
252
-
253
- def get_row_data(row)
254
- row_count = get_row_count
255
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
256
- case @locator_type
257
- when :xpath
258
- row > 1 ?
259
- set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}[#{row}]") :
260
- set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}")
261
- when :css
262
- row > 1 ?
263
- set_alt_locator("#{@locator} > #{@table_body} > #{@table_row}:nth-of-type(#{row})") :
264
- set_alt_locator("#{@locator} > #{@table_body} > #{@table_row}")
265
- end
266
- value = get_value if exists?
267
- clear_alt_locator
268
- value
269
- end
270
-
271
- def get_table_column(column)
272
- rows = []
273
- column_count = get_column_count
274
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
275
- row_count = get_row_count
276
- (1..row_count).each do |row|
277
- value = ''
278
- set_table_cell_locator(row, column)
279
- saved_locator = @alt_locator
280
- case @locator_type
281
- when :xpath
282
- set_alt_locator("#{saved_locator}//input")
283
- unless exists?
284
- set_alt_locator("#{saved_locator}//textarea")
285
- set_alt_locator(saved_locator) unless exists?
286
- end
287
- when :css
288
- set_alt_locator("#{saved_locator} input")
289
- unless exists?
290
- set_alt_locator("#{saved_locator} textarea")
291
- set_alt_locator(saved_locator) unless exists?
292
- end
293
- end
294
- value = get_value if exists?
295
- rows.push(value)
296
- end
297
- clear_alt_locator
298
- rows
299
- end
300
-
301
- # Return text contained in specified cell of a table object.
302
- #
303
- # @param row [Integer] row number
304
- # @param column [Integer] column number
305
- # @return [String] value of table cell
306
- # @example
307
- # list_table.get_table_cell(4, 5)
308
- #
309
- def get_table_cell(row, column)
310
- row_count = get_row_count
311
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
312
- column_count = get_column_count
313
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
314
- set_table_cell_locator(row, column)
315
- saved_locator = @alt_locator
316
- case @locator_type
317
- when :xpath
318
- set_alt_locator("#{saved_locator}//input")
319
- unless exists?
320
- set_alt_locator("#{saved_locator}//textarea")
321
- set_alt_locator(saved_locator) unless exists?
322
- end
323
- when :css
324
- set_alt_locator("#{saved_locator} input")
325
- unless exists?
326
- set_alt_locator("#{saved_locator} textarea")
327
- set_alt_locator(saved_locator) unless exists?
328
- end
329
- end
330
- if exists?
331
- value = get_value
332
- else
333
- puts "Could not find table cell at #{@alt_locator}"
334
- value = ''
335
- end
336
- clear_alt_locator
337
- value
338
- end
339
-
340
- def verify_table_cell(row, column, expected, enqueue = false)
341
- actual = get_table_cell(row, column)
342
- enqueue ?
343
- ExceptionQueue.enqueue_assert_equal(expected.strip, actual.strip, "Expected table #{object_ref_message} row #{row}/column #{column}") :
344
- assert_equal(expected.strip, actual.strip, "Expected table #{object_ref_message} row #{row}/column #{column} to display '#{expected}' but found '#{actual}'")
345
- end
346
-
347
- # Set the value of the specified cell in a table object.
348
- #
349
- # @param row [Integer] row number
350
- # @param column [Integer] column number
351
- # @param value [String] text to set
352
- # @example
353
- # list_table.set_table_cell(3, 1, 'Ontario')
354
- #
355
- def set_table_cell(row, column, value)
356
- row_count = get_row_count
357
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
358
- find_table_cell(row, column)
359
- find_table_cell(row, column) unless exists?
360
- set(value)
361
- clear_alt_locator
362
- end
363
-
364
- def get_cell_attribute(row, column, attrib)
365
- row_count = get_row_count
366
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
367
- column_count = get_column_count
368
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
369
- set_table_cell_locator(row, column)
370
- result = get_native_attribute(attrib)
371
- clear_alt_locator
372
- result
373
- end
374
-
375
- def get_row_attribute(row, attrib)
376
- row_count = get_row_count
377
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
378
- case @locator_type
379
- when :xpath
380
- row > 1 ?
381
- set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}[#{row}]") :
382
- set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}")
383
- when :css
384
- row > 1 ?
385
- set_alt_locator("#{@locator} > #{@table_body} > #{@table_row}:nth-of-type(#{row})") :
386
- set_alt_locator("#{@locator} > #{@table_body} > #{@table_row}")
387
- end
388
- result = get_native_attribute(attrib)
389
- clear_alt_locator
390
- result
391
- end
392
-
393
- def find_row_attribute(attrib, search_value)
394
- (1..get_row_count).each do |row|
395
- return row if get_row_attribute(row, attrib) == search_value
396
- end
397
- nil
398
- end
399
-
400
- # Search for the specified text value in the specified row of the table object.
401
- # Returns the number of the first column that contains the search value.
402
- #
403
- # @param row [Integer] row nummber
404
- # @param search_value [String] value to be searched for
405
- # @return [Integer] column number of table cell that contains search value
406
- # @example
407
- # bom_table.find_in_table_row(4, 'High-speed Framus bolts')
408
- #
409
- def find_in_table_row(row, search_value)
410
- (1..get_column_count).each do |column|
411
- return column if get_table_cell(row, column) == search_value
412
- end
413
- nil
414
- end
415
-
416
- # Search for the specified text value in the specified column of the table object.
417
- # Returns the number of the first row that contains the search value.
418
- #
419
- # @param column [Integer] column nummber
420
- # @param search_value [String] value to be searched for
421
- # @return [Integer] row number of table cell that contains search value
422
- # @example
423
- # playlist_table.find_in_table_column(1, 'Ashes to Ashes')
424
- #
425
- def find_in_table_column(column, search_value)
426
- (1..get_row_count).each do |row|
427
- return row if get_table_cell(row, column) == search_value
428
- end
429
- nil
430
- end
431
-
432
- # Populate the specified row of this table object with the associated data from a Hash passed as an
433
- # argument. Data values must be in the form of a String for textfield and select list controls. For checkbox
434
- # and radio buttons, data must either be a Boolean or a String that evaluates to a Boolean value (Yes, No, 1,
435
- # 0, true, false)
436
- #
437
- # @param data [Hash] column numbers and associated data to be entered
438
- # @example
439
- # data = { 1 => 'Dr.',
440
- # 2 => 'Evangeline',
441
- # 3 => 'Devereaux',
442
- # 4 => 'MD',
443
- # 5 => 'Family Practice'
444
- # }
445
- # clinicians_table.populate_table_row(3, data)
446
- #
447
- def populate_table_row(row, data)
448
- wait_until_exists(2)
449
- data.each do |column, data_param|
450
- unless data_param.blank?
451
- if data_param == '!DELETE'
452
- set_table_cell(row, column, '')
453
- else
454
- set_table_cell(row, column, data_param)
455
- end
456
- end
457
- end
458
- end
459
-
460
- # Click in the specified column header in a table object.
461
- #
462
- # @param column [Integer] column number
463
- # @example
464
- # list_table.click_header_column(3)
465
- #
466
- def click_header_column(column)
467
- column_count = get_column_count
468
- raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{object_ref_message}" if column > column_count
469
- case @locator_type
470
- when :xpath
471
- set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
472
- when :css
473
- set_alt_locator("#{@locator} #{@table_header} > #{@header_row} > #{@header_column}:nth-of-type(#{column})")
474
- end
475
- click if exists?
476
- clear_alt_locator
477
- end
478
-
479
- def get_header_column(column)
480
- column_count = get_column_count
481
- raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{object_ref_message}" if column > column_count
482
- case @locator_type
483
- when :xpath
484
- set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
485
- when :css
486
- set_alt_locator("#{@locator} #{@table_header} > #{@header_row} > #{@header_column}:nth-of-type(#{column})")
487
- end
488
- value = get_value(:all) if exists?(:all)
489
- clear_alt_locator
490
- value
491
- end
492
-
493
- def get_header_columns
494
- columns = []
495
- column_count = get_column_count
496
- (1..column_count).each do |column|
497
- case @locator_type
498
- when :xpath
499
- set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
500
- when :css
501
- set_alt_locator("#{@locator} #{@table_header} > #{@header_row} > #{@header_column}:nth-of-type(#{column})")
502
- end
503
- columns.push(get_value(:all)) if exists?(:all)
504
- end
505
- clear_alt_locator
506
- columns
507
- end
508
-
509
- def is_table_row_expanded?(row, column)
510
- row_count = get_row_count
511
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
512
- column_count = get_column_count
513
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
514
- set_table_cell_locator(row, column)
515
- case @locator_type
516
- when :xpath
517
- set_alt_locator("#{@alt_locator}/#{@tree_expand}")
518
- when :css
519
- set_alt_locator("#{@alt_locator} > #{@tree_expand}")
520
- end
521
- expanded = true
522
- expanded = false if exists?
523
- clear_alt_locator
524
- expanded
525
- end
526
-
527
- def expand_table_row(row, column)
528
- unless is_table_row_expanded?(row, column)
529
- set_table_cell_locator(row, column)
530
- case @locator_type
531
- when :xpath
532
- set_alt_locator("#{@alt_locator}/#{@tree_expand}")
533
- when :css
534
- set_alt_locator("#{@alt_locator} > #{@tree_expand}")
535
- end
536
- click if exists?
537
- clear_alt_locator
538
- end
539
- end
540
-
541
- def collapse_table_row(row, column)
542
- if is_table_row_expanded?(row, column)
543
- set_table_cell_locator(row, column)
544
- case @locator_type
545
- when :xpath
546
- set_alt_locator("#{@alt_locator}/#{@tree_collapse}")
547
- when :css
548
- set_alt_locator("#{@alt_locator} > #{@tree_collapse}")
549
- end
550
- click if exists?
551
- clear_alt_locator
552
- end
553
- end
554
-
555
- def expand_all_table_rows(column)
556
- row_count = get_row_count
557
- column_count = get_column_count
558
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
559
- row_count.downto(1) do |row|
560
- expand_table_row(row, column)
561
- end
562
- end
563
-
564
- def get_table_cell_locator(row, column)
565
- case @locator_type
566
- when :xpath
567
- if @table_section.nil?
568
- row_spec = "#{@locator}/#{@table_body}/#{@table_row}"
569
- row_spec = "#{row_spec}[#{row}]"
570
- else
571
- row_spec = "#{@locator}/#{@table_body}/#{@table_section}"
572
- row_spec = "#{row_spec}[#{row}]/#{@table_row}[1]"
573
- end
574
- column_spec = "/#{@table_column}[#{column}]"
575
- when :css
576
- if @table_section.nil?
577
- row_spec = "#{@locator} > #{@table_body} > #{@table_row}"
578
- row_spec = "#{row_spec}:nth-of-type(#{row})"
579
- else
580
- row_spec = "#{@locator} > #{@table_body} > #{@table_section}"
581
- row_spec = "#{row_spec}:nth-of-type(#{row}) > #{@table_row}:nth-of-type(1)"
582
- end
583
- column_spec = " > #{@table_column}:nth-of-type(#{column})"
584
- end
585
- "#{row_spec}#{column_spec}"
586
- end
587
-
588
- private
589
-
590
- def set_table_cell_locator(row, column)
591
- set_alt_locator(get_table_cell_locator(row, column))
592
- end
593
-
594
- def find_table_cell(row, column)
595
- set_table_cell_locator(row, column)
596
- if exists?
597
- click
598
- else
599
- puts "Could not find table cell at #{@alt_locator}"
600
- end
601
- saved_locator = @alt_locator
602
- case @locator_type
603
- when :xpath
604
- set_alt_locator("#{saved_locator}//input")
605
- set_alt_locator("#{saved_locator}//textarea") unless exists?
606
- when :css
607
- set_alt_locator("#{saved_locator} input")
608
- set_alt_locator("#{saved_locator} textarea") unless exists?
609
- end
610
- end
611
- end
612
- end