testcentricity_web 3.3.0 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -0
  3. data/Gemfile.lock +23 -25
  4. data/README.md +66 -33
  5. data/lib/testcentricity_web/browser_helper.rb +21 -13
  6. data/lib/testcentricity_web/data_objects/data_objects_helper.rb +34 -5
  7. data/lib/testcentricity_web/data_objects/environment.rb +30 -5
  8. data/lib/testcentricity_web/data_objects/excel_helper.rb +1 -25
  9. data/lib/testcentricity_web/version.rb +1 -1
  10. data/lib/testcentricity_web/web_core/page_object.rb +1 -93
  11. data/lib/testcentricity_web/web_core/page_objects_helper.rb +1 -7
  12. data/lib/testcentricity_web/web_core/page_section.rb +0 -91
  13. data/lib/testcentricity_web/web_core/webdriver_helper.rb +89 -31
  14. data/lib/testcentricity_web/web_elements/checkbox.rb +1 -15
  15. data/lib/testcentricity_web/web_elements/file_field.rb +1 -1
  16. data/lib/testcentricity_web/web_elements/radio.rb +1 -1
  17. data/lib/testcentricity_web/web_elements/select_list.rb +0 -52
  18. data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +5 -14
  19. data/lib/testcentricity_web/world_extensions.rb +1 -1
  20. data/lib/testcentricity_web.rb +0 -11
  21. metadata +6 -17
  22. data/lib/testcentricity_web/web_elements/cell_button.rb +0 -8
  23. data/lib/testcentricity_web/web_elements/cell_checkbox.rb +0 -38
  24. data/lib/testcentricity_web/web_elements/cell_element.rb +0 -69
  25. data/lib/testcentricity_web/web_elements/cell_image.rb +0 -8
  26. data/lib/testcentricity_web/web_elements/cell_radio.rb +0 -31
  27. data/lib/testcentricity_web/web_elements/list_button.rb +0 -8
  28. data/lib/testcentricity_web/web_elements/list_checkbox.rb +0 -38
  29. data/lib/testcentricity_web/web_elements/list_element.rb +0 -61
  30. data/lib/testcentricity_web/web_elements/list_radio.rb +0 -31
  31. data/lib/testcentricity_web/web_elements/siebel_open_ui_helper.rb +0 -15
@@ -5,8 +5,7 @@ module TestCentricity
5
5
  # @param element_name [Symbol] name of UI object (as a symbol)
6
6
  # @param locator [String] CSS selector or XPath expression that uniquely identifies object
7
7
  # @example
8
- # element :siebel_view, 'div#_sweview'
9
- # element :siebel_busy, "//html[contains(@class, 'siebui-busy')]"
8
+ # element :settings_item, 'a#userPreferencesTrigger'
10
9
  #
11
10
  def self.element(element_name, locator)
12
11
  define_page_element(element_name, TestCentricity::UIElement, locator)
@@ -288,97 +287,6 @@ module TestCentricity
288
287
  element_hash.each(&method(:filefield))
289
288
  end
290
289
 
291
- # Declare and instantiate a cell button in a table column on this page object.
292
- #
293
- # @param element_name [Symbol] name of cell button object (as a symbol)
294
- # @param locator [String] XPath expression that uniquely identifies cell button within row and column of parent table object
295
- # @param table [Symbol] Name (as a symbol) of parent table object
296
- # @param column [Integer] 1-based index of table column that contains the cell button object
297
- # @example
298
- # cell_button :show_button, "a[@class='show']", :data_table, 5
299
- # cell_button :edit_button, "a[@class='edit']", :data_table, 5
300
- #
301
- def self.cell_button(element_name, locator, table, column)
302
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellButton.new("#{element_name}", self, "#{locator}", :page, #{table}, #{column});end))
303
- end
304
-
305
- # Declare and instantiate a cell checkbox in a table column on this page object.
306
- #
307
- # @param element_name [Symbol] name of cell checkbox object (as a symbol)
308
- # @param locator [String] XPath expression that uniquely identifies cell checkbox within row and column of parent table object
309
- # @param table [Symbol] Name (as a symbol) of parent table object
310
- # @param column [Integer] 1-based index of table column that contains the cell checkbox object
311
- # @example
312
- # cell_checkbox :is_registered_check, "a[@class='registered']", :data_table, 4
313
- #
314
- def self.cell_checkbox(element_name, locator, table, column, proxy = nil)
315
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellCheckBox.new("#{element_name}", self, "#{locator}", :page, #{table}, #{column}, #{proxy});end))
316
- end
317
-
318
- # Declare and instantiate a cell radio in a table column on this page object.
319
- #
320
- # @param element_name [Symbol] name of cell radio object (as a symbol)
321
- # @param locator [String] XPath expression that uniquely identifies cell radio within row and column of parent table object
322
- # @param table [Symbol] Name (as a symbol) of parent table object
323
- # @param column [Integer] 1-based index of table column that contains the cell radio object
324
- # @example
325
- # cell_radio :track_a_radio, "a[@class='track_a']", :data_table, 8
326
- #
327
- def self.cell_radio(element_name, locator, table, column, proxy = nil)
328
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellRadio.new("#{element_name}", self, "#{locator}", :page, #{table}, #{column}, #{proxy});end))
329
- end
330
-
331
- # Declare and instantiate a cell image in a table column on this page object.
332
- #
333
- # @param element_name [Symbol] name of cell image object (as a symbol)
334
- # @param locator [String] XPath expression that uniquely identifies cell image within row and column of parent table object
335
- # @param table [Symbol] Name (as a symbol) of parent table object
336
- # @param column [Integer] 1-based index of table column that contains the cell image object
337
- # @example
338
- # cell_image :ready_icon, "img[@class='ready']", :data_table, 3
339
- # cell_image :send_icon, "img[@class='send']", :data_table, 3
340
- #
341
- def self.cell_image(element_name, locator, table, column)
342
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellImage.new("#{element_name}", self, "#{locator}", :page, #{table}, #{column});end))
343
- end
344
-
345
- # Declare and instantiate a list button in a row of a list object on this page object.
346
- #
347
- # @param element_name [Symbol] name of list button object (as a symbol)
348
- # @param locator [String] XPath expression that uniquely identifies list button within row of parent list object
349
- # @param list [Symbol] Name (as a symbol) of parent list object
350
- # @example
351
- # list_button :delete_button, "a[@class='delete']", :icon_list
352
- # list_button :edit_button, "a[@class='edit']", :icon_list
353
- #
354
- def self.list_button(element_name, locator, list)
355
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListButton.new("#{element_name}", self, "#{locator}", :page, #{list});end))
356
- end
357
-
358
- # Declare and instantiate a list checkbox in a row of a list object on this page object.
359
- #
360
- # @param element_name [Symbol] name of list checkbox object (as a symbol)
361
- # @param locator [String] XPath expression that uniquely identifies list checkbox within row of parent list object
362
- # @param list [Symbol] Name (as a symbol) of parent list object
363
- # @example
364
- # list_checkbox :is_registered_check, "a[@class='registered']", :data_list
365
- #
366
- def self.list_checkbox(element_name, locator, list, proxy = nil)
367
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListCheckBox.new("#{element_name}", self, "#{locator}", :page, #{list}, #{proxy});end))
368
- end
369
-
370
- # Declare and instantiate a list radio in a row of a list object on this page object.
371
- #
372
- # @param element_name [Symbol] name of list radio object (as a symbol)
373
- # @param locator [String] XPath expression that uniquely identifies list radio within row of parent list object
374
- # @param list [Symbol] Name (as a symbol) of parent list object
375
- # @example
376
- # list_radio :sharing_radio, "a[@class='sharing']", :data_list
377
- #
378
- def self.list_radio(element_name, locator, list, proxy = nil)
379
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListRadio.new("#{element_name}", self, "#{locator}", :page, #{list}, #{proxy});end))
380
- end
381
-
382
290
  # Instantiate a single PageSection object for this page object.
383
291
  #
384
292
  # @param section_name [Symbol] name of PageSection object (as a symbol)
@@ -137,8 +137,6 @@ module TestCentricity
137
137
  ui_object.count(visible = true)
138
138
  when :count_all
139
139
  ui_object.count(visible = :all)
140
- when :siebel_options
141
- ui_object.get_siebel_options
142
140
  when :style
143
141
  ui_object.style
144
142
  when :href
@@ -282,11 +280,7 @@ module TestCentricity
282
280
  check_state = data_param.is_a?(String) ? data_param.to_bool : data_param
283
281
  data_field.set_checkbox_state(check_state)
284
282
  when :selectlist
285
- if data_field.get_siebel_object_type == 'JComboBox'
286
- data_field.set("#{data_param}\t")
287
- else
288
- data_field.choose_option(data_param)
289
- end
283
+ data_field.choose_option(data_param)
290
284
  when :radio
291
285
  check_state = data_param.is_a?(String) ? data_param.to_bool : data_param
292
286
  data_field.set_selected_state(check_state)
@@ -407,97 +407,6 @@ module TestCentricity
407
407
  element_hash.each(&method(:filefield))
408
408
  end
409
409
 
410
- # Declare and instantiate a cell button in a table column on this page section.
411
- #
412
- # @param element_name [Symbol] name of cell button object (as a symbol)
413
- # @param locator [String] XPath expression that uniquely identifies cell button within row and column of parent table object
414
- # @param table [Symbol] Name (as a symbol) of parent table object
415
- # @param column [Integer] 1-based index of table column that contains the cell button object
416
- # @example
417
- # cell_button :show_button, "a[@class='show']", :data_table, 5
418
- # cell_button :edit_button, "a[@class='edit']", :data_table, 5
419
- #
420
- def self.cell_button(element_name, locator, table, column)
421
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellButton.new("#{element_name}", self, "#{locator}", :section, #{table}, #{column});end))
422
- end
423
-
424
- # Declare and instantiate a cell checkbox in a table column on this page section.
425
- #
426
- # @param element_name [Symbol] name of cell checkbox object (as a symbol)
427
- # @param locator [String] XPath expression that uniquely identifies cell checkbox within row and column of parent table object
428
- # @param table [Symbol] Name (as a symbol) of parent table object
429
- # @param column [Integer] 1-based index of table column that contains the cell checkbox object
430
- # @example
431
- # cell_checkbox :is_registered_check, "a[@class='registered']", :data_table, 4
432
- #
433
- def self.cell_checkbox(element_name, locator, table, column, proxy = nil)
434
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellCheckBox.new("#{element_name}", self, "#{locator}", :section, #{table}, #{column}, #{proxy});end))
435
- end
436
-
437
- # Declare and instantiate a cell radio in a table column on this page section.
438
- #
439
- # @param element_name [Symbol] name of cell radio object (as a symbol)
440
- # @param locator [String] XPath expression that uniquely identifies cell radio within row and column of parent table object
441
- # @param table [Symbol] Name (as a symbol) of parent table object
442
- # @param column [Integer] 1-based index of table column that contains the cell radio object
443
- # @example
444
- # cell_radio :track_a_radio, "a[@class='track_a']", :data_table, 8
445
- #
446
- def self.cell_radio(element_name, locator, table, column, proxy = nil)
447
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellRadio.new("#{element_name}", self, "#{locator}", :section, #{table}, #{column}, #{proxy});end))
448
- end
449
-
450
- # Declare and instantiate a cell image in a table column on this page object.
451
- #
452
- # @param element_name [Symbol] name of cell image object (as a symbol)
453
- # @param locator [String] XPath expression that uniquely identifies cell image within row and column of parent table object
454
- # @param table [Symbol] Name (as a symbol) of parent table object
455
- # @param column [Integer] 1-based index of table column that contains the cell image object
456
- # @example
457
- # cell_image :ready_icon, "img[@class='ready']", :data_table, 3
458
- # cell_image :send_icon, "img[@class='send']", :data_table, 3
459
- #
460
- def self.cell_image(element_name, locator, table, column)
461
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellImage.new("#{element_name}", self, "#{locator}", :section, #{table}, #{column});end))
462
- end
463
-
464
- # Declare and instantiate a list button in a row of a list object on this section object.
465
- #
466
- # @param element_name [Symbol] name of list button object (as a symbol)
467
- # @param locator [String] XPath expression that uniquely identifies list button within row of parent list object
468
- # @param list [Symbol] Name (as a symbol) of parent list object
469
- # @example
470
- # list_button :delete_button, "a[@class='delete']", :icon_list
471
- # list_button :edit_button, "a[@class='edit']", :icon_list
472
- #
473
- def self.list_button(element_name, locator, list)
474
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListButton.new("#{element_name}", self, "#{locator}", :section, #{list});end))
475
- end
476
-
477
- # Declare and instantiate a list checkbox in a row of a list object on this section object.
478
- #
479
- # @param element_name [Symbol] name of list checkbox object (as a symbol)
480
- # @param locator [String] XPath expression that uniquely identifies list checkbox within row of parent list object
481
- # @param list [Symbol] Name (as a symbol) of parent list object
482
- # @example
483
- # list_checkbox :is_registered_check, "a[@class='registered']", :data_list
484
- #
485
- def self.list_checkbox(element_name, locator, list, proxy = nil)
486
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListCheckBox.new("#{element_name}", self, "#{locator}", :section, #{list}, #{proxy});end))
487
- end
488
-
489
- # Declare and instantiate a list radio in a row of a list object on this section object.
490
- #
491
- # @param element_name [Symbol] name of list radio object (as a symbol)
492
- # @param locator [String] XPath expression that uniquely identifies list radio within row of parent list object
493
- # @param list [Symbol] Name (as a symbol) of parent list object
494
- # @example
495
- # list_radio :sharing_radio, "a[@class='sharing']", :data_list
496
- #
497
- def self.list_radio(element_name, locator, list, proxy = nil)
498
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellRadio.new("#{element_name}", self, "#{locator}", :section, #{list}, #{proxy});end))
499
- end
500
-
501
410
  # Instantiate a single PageSection object within this PageSection object.
502
411
  #
503
412
  # @param section_name [Symbol] name of PageSection object (as a symbol)
@@ -6,14 +6,23 @@ require 'fileutils'
6
6
 
7
7
 
8
8
  module TestCentricity
9
- module WebDriverConnect
9
+ class WebDriverConnect
10
10
  include Capybara::DSL
11
11
 
12
12
  attr_accessor :bs_local
13
13
  attr_accessor :downloads_path
14
14
 
15
- def self.initialize_web_driver(app_host = nil)
16
- Capybara.app_host = app_host unless app_host.nil?
15
+ def self.initialize_web_driver(options = nil)
16
+ desired_caps = nil
17
+ merge_caps = nil
18
+ if options.is_a?(String)
19
+ Capybara.app_host = options
20
+ elsif options.is_a?(Hash)
21
+ Capybara.app_host = options[:app_host] if options.key?(:app_host)
22
+ desired_caps = options[:desired_capabilities] if options.key?(:desired_capabilities)
23
+ merge_caps = options[:merge_capabilities] if options.key?(:merge_capabilities)
24
+ end
25
+
17
26
  browser = ENV['WEB_BROWSER']
18
27
  # set downloads folder path
19
28
  @downloads_path = "#{Dir.pwd}/downloads"
@@ -37,25 +46,25 @@ module TestCentricity
37
46
 
38
47
  context = case browser.downcase.to_sym
39
48
  when :appium
40
- initialize_appium
49
+ initialize_appium(desired_caps, merge_caps)
41
50
  'mobile device emulator'
42
51
  when :browserstack
43
- initialize_browserstack
52
+ initialize_browserstack(desired_caps, merge_caps)
44
53
  'Browserstack cloud service'
45
54
  when :crossbrowser
46
- initialize_crossbrowser
55
+ initialize_crossbrowser(desired_caps, merge_caps)
47
56
  'CrossBrowserTesting cloud service'
48
57
  when :gridlastic
49
- initialize_gridlastic
58
+ initialize_gridlastic(desired_caps, merge_caps)
50
59
  'Gridlastic cloud service'
51
60
  when :lambdatest
52
- initialize_lambdatest
61
+ initialize_lambdatest(desired_caps, merge_caps)
53
62
  'LambdaTest cloud service'
54
63
  when :saucelabs
55
- initialize_saucelabs
64
+ initialize_saucelabs(desired_caps, merge_caps)
56
65
  'Sauce Labs cloud service'
57
66
  when :testingbot
58
- initialize_testingbot
67
+ initialize_testingbot(desired_caps, merge_caps)
59
68
  'TestingBot cloud service'
60
69
  else
61
70
  if ENV['SELENIUM'] == 'remote'
@@ -124,7 +133,7 @@ module TestCentricity
124
133
 
125
134
  private
126
135
 
127
- def self.initialize_appium
136
+ def self.initialize_appium(desired_caps = nil, merge_caps = false)
128
137
  Environ.platform = :mobile
129
138
  Environ.device_name = ENV['APP_DEVICE']
130
139
  Environ.device_os = ENV['APP_PLATFORM_NAME'].downcase.to_sym
@@ -183,6 +192,10 @@ module TestCentricity
183
192
  desired_capabilities[:systemPort] = ENV['SYSTEM_PORT'] if ENV['SYSTEM_PORT']
184
193
  end
185
194
 
195
+ unless desired_caps.nil?
196
+ desired_capabilities = merge_caps ? desired_capabilities.merge(desired_caps) : desired_caps
197
+ end
198
+
186
199
  Capybara.register_driver :appium do |app|
187
200
  appium_lib_options = { server_url: endpoint }
188
201
  all_options = {
@@ -198,6 +211,8 @@ module TestCentricity
198
211
  'OS X'
199
212
  elsif OS.windows?
200
213
  'Windows'
214
+ elsif OS.linux?
215
+ 'Linux'
201
216
  end
202
217
 
203
218
  browser = ENV['WEB_BROWSER'].downcase.to_sym
@@ -216,8 +231,8 @@ module TestCentricity
216
231
  Capybara.register_driver :selenium do |app|
217
232
  case browser
218
233
  when :safari
219
- desired_caps = Selenium::WebDriver::Remote::Capabilities.safari(cleanSession: true)
220
- Capybara::Selenium::Driver.new(app, browser: browser, desired_capabilities: desired_caps)
234
+ caps = Selenium::WebDriver::Remote::Capabilities.safari(cleanSession: true)
235
+ Capybara::Selenium::Driver.new(app, browser: browser, desired_capabilities: caps)
221
236
  when :ie, :edge
222
237
  Capybara::Selenium::Driver.new(app, browser: browser)
223
238
  when :firefox, :firefox_headless
@@ -248,6 +263,7 @@ module TestCentricity
248
263
  }
249
264
  options.add_preference(:download, prefs)
250
265
  options.add_argument('--disable-infobars')
266
+ options.add_argument('--disable-dev-shm-usage')
251
267
  options.add_argument("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
252
268
  if browser == :chrome_headless
253
269
  options.add_argument('--headless')
@@ -255,11 +271,13 @@ module TestCentricity
255
271
  options.add_argument('--no-sandbox')
256
272
  end
257
273
 
258
- Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) else
274
+ Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
275
+ else
259
276
  if ENV['HOST_BROWSER'] && ENV['HOST_BROWSER'].downcase.to_sym == :chrome
260
277
  user_agent = Browsers.mobile_device_agent(ENV['WEB_BROWSER'])
261
278
  options = Selenium::WebDriver::Chrome::Options.new
262
279
  options.add_argument('--disable-infobars')
280
+ options.add_argument('--disable-dev-shm-usage')
263
281
  options.add_argument("--user-agent='#{user_agent}'")
264
282
  options.add_argument("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
265
283
  Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
@@ -271,7 +289,7 @@ module TestCentricity
271
289
  Capybara.default_driver = :selenium
272
290
  end
273
291
 
274
- def self.initialize_browserstack
292
+ def self.initialize_browserstack(desired_caps = nil, merge_caps = false)
275
293
  browser = ENV['BS_BROWSER']
276
294
  Environ.grid = :browserstack
277
295
 
@@ -283,19 +301,22 @@ module TestCentricity
283
301
  elsif ENV['BS_OS']
284
302
  Environ.os = "#{ENV['BS_OS']} #{ENV['BS_OS_VERSION']}"
285
303
  end
304
+ Environ.device = if ENV['BS_REAL_MOBILE']
305
+ :device
306
+ elsif ENV['BS_PLATFORM']
307
+ :simulator
308
+ end
286
309
 
287
310
  endpoint = "http://#{ENV['BS_USERNAME']}:#{ENV['BS_AUTHKEY']}@hub-cloud.browserstack.com/wd/hub"
288
311
  Capybara.register_driver :browserstack do |app|
289
312
  capabilities = Selenium::WebDriver::Remote::Capabilities.new
290
313
 
291
314
  if ENV['BS_REAL_MOBILE']
292
- Environ.device = :device
293
315
  capabilities['device'] = ENV['BS_DEVICE']
294
316
  capabilities['realMobile'] = true
295
317
  capabilities['os_version'] = ENV['BS_OS_VERSION']
296
318
 
297
319
  elsif ENV['BS_PLATFORM']
298
- Environ.device = :simulator
299
320
  capabilities[:platform] = ENV['BS_PLATFORM']
300
321
  capabilities[:browserName] = browser
301
322
  capabilities['device'] = ENV['BS_DEVICE'] if ENV['BS_DEVICE']
@@ -357,6 +378,10 @@ module TestCentricity
357
378
  capabilities['cleanSession'] = 'true'
358
379
  end
359
380
 
381
+ unless desired_caps.nil?
382
+ capabilities = merge_caps ? capabilities.merge(desired_caps) : desired_caps
383
+ end
384
+
360
385
  if ENV['TUNNELING']
361
386
  @bs_local = BrowserStack::Local.new
362
387
  bs_local_args = {'key' => "#{ENV['BS_AUTHKEY']}"}
@@ -385,7 +410,7 @@ module TestCentricity
385
410
  end
386
411
  end
387
412
 
388
- def self.initialize_crossbrowser
413
+ def self.initialize_crossbrowser(desired_caps = nil, merge_caps = false)
389
414
  browser = ENV['CB_BROWSER']
390
415
  Environ.grid = :crossbrowser
391
416
 
@@ -412,6 +437,11 @@ module TestCentricity
412
437
  elsif ENV['CB_PLATFORM']
413
438
  capabilities['os_api_name'] = ENV['CB_PLATFORM']
414
439
  end
440
+
441
+ unless desired_caps.nil?
442
+ capabilities = merge_caps ? capabilities.merge(desired_caps) : desired_caps
443
+ end
444
+
415
445
  Capybara::Selenium::Driver.new(app, browser: :remote, url: endpoint, desired_capabilities: capabilities)
416
446
  end
417
447
 
@@ -427,12 +457,11 @@ module TestCentricity
427
457
  end
428
458
  end
429
459
 
430
- def self.initialize_gridlastic
460
+ def self.initialize_gridlastic(desired_caps = nil, merge_caps = false)
431
461
  browser = ENV['GL_BROWSER']
432
462
  Environ.grid = :gridlastic
433
463
  Environ.os = ENV['GL_OS']
434
464
  endpoint = "http://#{ENV['GL_USERNAME']}:#{ENV['GL_AUTHKEY']}@#{ENV['GL_SUBDOMAIN']}.gridlastic.com:80/wd/hub"
435
-
436
465
  capabilities = Selenium::WebDriver::Remote::Capabilities.new
437
466
  capabilities['browserName'] = browser
438
467
  capabilities['version'] = ENV['GL_VERSION'] if ENV['GL_VERSION']
@@ -440,6 +469,10 @@ module TestCentricity
440
469
  capabilities['platformName'] = ENV['GL_PLATFORM']
441
470
  capabilities['video'] = ENV['RECORD_VIDEO'].capitalize if ENV['RECORD_VIDEO']
442
471
 
472
+ unless desired_caps.nil?
473
+ capabilities = merge_caps ? capabilities.merge(desired_caps) : desired_caps
474
+ end
475
+
443
476
  Capybara.register_driver :selenium do |app|
444
477
  client = Selenium::WebDriver::Remote::Http::Default.new
445
478
  client.timeout = 1200
@@ -463,7 +496,7 @@ module TestCentricity
463
496
  end
464
497
  end
465
498
 
466
- def self.initialize_lambdatest
499
+ def self.initialize_lambdatest(desired_caps = nil, merge_caps = false)
467
500
  browser = ENV['LT_BROWSER']
468
501
  Environ.grid = :lambdatest
469
502
  Environ.os = ENV['LT_OS']
@@ -502,6 +535,10 @@ module TestCentricity
502
535
  end
503
536
  capabilities['build'] = context_message
504
537
 
538
+ unless desired_caps.nil?
539
+ capabilities = merge_caps ? capabilities.merge(desired_caps) : desired_caps
540
+ end
541
+
505
542
  Capybara::Selenium::Driver.new(app, browser: :remote, url: endpoint, desired_capabilities: capabilities)
506
543
  end
507
544
 
@@ -526,13 +563,23 @@ module TestCentricity
526
563
  when :firefox, :safari, :ie, :edge
527
564
  capabilities = Selenium::WebDriver::Remote::Capabilities.send(browser)
528
565
  when :chrome, :chrome_headless
529
- options = browser == :chrome ? %w[--disable-infobars] : %w[headless disable-gpu no-sandbox --disable-infobars]
566
+ options = %w[--disable-infobars]
567
+ options.push('--disable-dev-shm-usage')
530
568
  options.push("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
569
+ if browser == :chrome_headless
570
+ Environ.headless = true
571
+ options.push('--headless')
572
+ options.push('--disable-gpu')
573
+ options.push('--no-sandbox')
574
+ end
531
575
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome('goog:chromeOptions' => { args: options })
532
576
  else
533
577
  if ENV['HOST_BROWSER'] && ENV['HOST_BROWSER'].downcase.to_sym == :chrome
578
+ Environ.platform = :mobile
579
+ Environ.device_name = Browsers.mobile_device_name(ENV['WEB_BROWSER'])
534
580
  user_agent = Browsers.mobile_device_agent(ENV['WEB_BROWSER'])
535
581
  options = %w[--disable-infobars]
582
+ options.push('--disable-dev-shm-usage')
536
583
  options.push("--user-agent='#{user_agent}'")
537
584
  options.push("--lang=#{ENV['LOCALE']}") if ENV['LOCALE']
538
585
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome('goog:chromeOptions' => { args: options })
@@ -540,19 +587,22 @@ module TestCentricity
540
587
  raise "Requested browser '#{browser}' is not supported on Selenium Grid"
541
588
  end
542
589
  end
543
- Capybara::Selenium::Driver.new(app, browser: :remote, url: endpoint, desired_capabilities: capabilities)
590
+ Capybara::Selenium::Driver.new(app,
591
+ browser: :remote,
592
+ url: endpoint,
593
+ desired_capabilities: capabilities).tap do |driver|
594
+ # configure file_detector for remote uploads
595
+ driver.browser.file_detector = lambda do |args|
596
+ str = args.first.to_s
597
+ str if File.exist?(str)
598
+ end
599
+ end
544
600
  end
545
601
  Capybara.current_driver = :remote_browser
546
602
  Capybara.default_driver = :remote_browser
547
- # configure file_detector for remote uploads
548
- selenium = Capybara.page.driver.browser
549
- selenium.file_detector = lambda do |args|
550
- str = args.first.to_s
551
- str if File.exist?(str)
552
- end
553
603
  end
554
604
 
555
- def self.initialize_saucelabs
605
+ def self.initialize_saucelabs(desired_caps = nil, merge_caps = false)
556
606
  browser = ENV['SL_BROWSER']
557
607
  Environ.grid = :saucelabs
558
608
 
@@ -582,6 +632,10 @@ module TestCentricity
582
632
  capabilities['deviceOrientation'] = ENV['ORIENTATION'] if ENV['ORIENTATION']
583
633
  end
584
634
 
635
+ unless desired_caps.nil?
636
+ capabilities = merge_caps ? capabilities.merge(desired_caps) : desired_caps
637
+ end
638
+
585
639
  Capybara::Selenium::Driver.new(app, browser: :remote, url: endpoint, desired_capabilities: capabilities)
586
640
  end
587
641
 
@@ -597,7 +651,7 @@ module TestCentricity
597
651
  end
598
652
  end
599
653
 
600
- def self.initialize_testingbot
654
+ def self.initialize_testingbot(desired_caps = nil, merge_caps = false)
601
655
  browser = ENV['TB_BROWSER']
602
656
  Environ.grid = :testingbot
603
657
 
@@ -630,6 +684,10 @@ module TestCentricity
630
684
  capabilities['deviceName'] = ENV['TB_DEVICE']
631
685
  end
632
686
 
687
+ unless desired_caps.nil?
688
+ capabilities = merge_caps ? capabilities.merge(desired_caps) : desired_caps
689
+ end
690
+
633
691
  Capybara::Selenium::Driver.new(app, browser: :remote, url: endpoint, desired_capabilities: capabilities)
634
692
  end
635
693
 
@@ -117,7 +117,7 @@ module TestCentricity
117
117
  # remember_me_checkbox.uncheck
118
118
  #
119
119
  def uncheck
120
- set_checkbox_state(false)
120
+ set_checkbox_state(state = false)
121
121
  end
122
122
 
123
123
  def verify_check_state(state, enqueue = false)
@@ -127,20 +127,6 @@ module TestCentricity
127
127
  assert_equal(state, actual, "Expected checkbox #{object_ref_message} to be #{state} but found #{actual} instead")
128
128
  end
129
129
 
130
- # Set the check state of a Siebel OUI JCheckBox object.
131
- #
132
- # @param state [Boolean] true = checked / false = unchecked
133
- # @example
134
- # remember_me_checkbox.set_siebel_checkbox_state(true)
135
- #
136
- def set_siebel_checkbox_state(state)
137
- obj, = find_element
138
- object_not_found_exception(obj, 'Siebel checkbox')
139
- raise "UI #{object_ref_message} is not a Siebel CheckBox object" unless get_siebel_object_type == 'JCheckBox'
140
- expected = state.to_bool
141
- obj.click unless expected == obj.checked?
142
- end
143
-
144
130
  # Highlight a checkbox with a 3 pixel wide, red dashed border for the specified wait time.
145
131
  # If wait time is zero, then the highlight will remain until the page is refreshed
146
132
  #
@@ -12,7 +12,7 @@ module TestCentricity
12
12
  end
13
13
 
14
14
  def file_upload(file_path)
15
- obj, = find_element(false)
15
+ obj, = find_element(visible = false)
16
16
  obj.send_keys(file_path)
17
17
  end
18
18
 
@@ -101,7 +101,7 @@ module TestCentricity
101
101
  # accept_terms_radio.unselect
102
102
  #
103
103
  def unselect
104
- set_selected_state(false)
104
+ set_selected_state(state = false)
105
105
  end
106
106
 
107
107
  # Highlight a radio button with a 3 pixel wide, red dashed border for the specified wait time.
@@ -258,58 +258,6 @@ module TestCentricity
258
258
 
259
259
  alias selected? get_selected_option
260
260
 
261
- # Select the specified option in a Siebel OUI select box object.
262
- #
263
- # @param option [String] text of option to select
264
- # @example
265
- # country_select.choose_siebel_option('Cayman Islands')
266
- #
267
- def choose_siebel_option(option)
268
- Capybara.wait_on_first_by_default = true
269
- invoke_siebel_popup
270
- first(:xpath, "//li[@class='ui-menu-item']", exact: true, match: :prefer_exact, text: option).click
271
- end
272
-
273
- # Return array of strings of all options in a Siebel OUI select box object.
274
- #
275
- # @return [Array]
276
- # @example
277
- # all_countries = country_select.get_siebel_options
278
- #
279
- def get_siebel_options
280
- invoke_siebel_popup
281
- sleep(0.5)
282
- options = page.all(:xpath, "//li[@class='ui-menu-item']").collect(&:text)
283
- @base_object, = find_element
284
- @base_object.native.send_keys(:escape)
285
- options
286
- end
287
-
288
- def verify_siebel_options(expected, enqueue = false)
289
- invoke_siebel_popup
290
- sleep(0.5)
291
- actual = page.all(:xpath, "//li[@class='ui-menu-item']").collect(&:text)
292
- if enqueue
293
- ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected list of options in list #{object_ref_message}")
294
- else
295
- assert_equal(expected, actual, "Expected list of options in list #{object_ref_message} to be #{expected} but found #{actual}")
296
- end
297
- @base_object, = find_element
298
- @base_object.native.send_keys(:escape)
299
- end
300
-
301
- # Is Siebel JComboBox set to read-only?
302
- #
303
- # @return [Boolean]
304
- # @example
305
- # country_select.read_only?
306
- #
307
- def read_only?
308
- @base_object, = find_element
309
- object_not_found_exception(@base_object, nil)
310
- !@base_object.native.attribute('readonly')
311
- end
312
-
313
261
  private
314
262
 
315
263
  def select_item(obj, option)