testcentricity_web 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4edaaa4fcef2bdc3bbc2f414b813069f26ffcda
4
- data.tar.gz: aa80ace49bf4cf496510969d29bf1742f7aa3ae1
3
+ metadata.gz: 214487a9e45246207338458bbc6720ccb33af966
4
+ data.tar.gz: 13309a0b1bbb525346e199f59bdb6d84d50bbebd
5
5
  SHA512:
6
- metadata.gz: 648db7efaf75de5d614f30486536567322a4491454ade71185bf39a070ef5ab85a77015f60729bde54e1954e67941a5b8299cdf7dffb6f55f85d384454b344ec
7
- data.tar.gz: 53201ce9d75df3a32fa301963a0ab83049e9c096691c4bd2173f87a997170e23049ce273a846a05c92066e0921e359411e688a431277c68d1bd31b9ef1ab2886
6
+ metadata.gz: 3f4d9724ca08942d7754389e1ca7d9a09ba049de735c0e826fdd0a7400900687d342bde4def56c8aa376592801d092da5afefcdf44696c508357646082d51de5
7
+ data.tar.gz: 3854b1bee3cc8325e65098129f993176899a49beab773b38e82e2b1b2bda37d3c1d76393d612ed5f2b33b1c53e7b36de1b6c802d9dda1acee1b14145dce5f834
data/README.md CHANGED
@@ -346,6 +346,14 @@ For locally hosted desktop web browsers, the `WEB_BROWSER` Environment Variable
346
346
  `edge` | Windows 10 only
347
347
  `poltergeist` | OS X or Windows
348
348
 
349
+ To set the size of a desktop browser window, you set the `BROWSER_SIZE` Environment Variable to the desired width and height in pixels as shown below:
350
+
351
+ BROWSER_SIZE=1600,1000
352
+
353
+ To maximize a desktop browser window, you set the `BROWSER_SIZE` Environment Variable to 'max' as shown below:
354
+
355
+ BROWSER_SIZE=max
356
+
349
357
 
350
358
  ### Locally hosted emulated mobile web browser
351
359
 
@@ -391,9 +399,10 @@ the table below. Refer to the [Browserstack-specific capabilities chart page](ht
391
399
  `BS_OS` | Must be set to `OS X` or `Windows`
392
400
  `BS_OS_VERSION` | Refer to `os_version` capability in chart
393
401
  `BS_BROWSER` | Refer to `browser` capability in chart
394
- `BS_VERSION` | Refer to `browser_version` capability in chart
402
+ `BS_VERSION` | [Optional] Refer to `browser_version` capability in chart. If not specified, latest stable version of browser will be used.
395
403
  `TUNNELING` | Must be `true` if you are testing against internal/local servers
396
- `RESOLUTION` | Refer to supported screen `resolution` capability in chart
404
+ `RESOLUTION` | [Optional] Refer to supported screen `resolution` capability in chart
405
+ `BROWSER_SIZE`| [Optional] Specify width, height of browser window
397
406
 
398
407
 
399
408
  #### Remote mobile browsers on the BrowserStack service
@@ -410,7 +419,7 @@ the table below. Refer to the [Browserstack-specific capabilities chart page](ht
410
419
  `BS_PLATFORM` | Must be set to `MAC` (for iOS) or `ANDROID`
411
420
  `BS_DEVICE` | Refer to `device` capability in chart
412
421
  `TUNNELING` | Must be `true` if you are testing against internal/local servers
413
- `ORIENTATION` | set to `portrait` or `landscape`
422
+ `ORIENTATION` | [Optional] Set to `portrait` or `landscape`
414
423
 
415
424
 
416
425
 
@@ -426,7 +435,8 @@ the table below. Use the Configuration Wizard on the [Start a Selenium Test page
426
435
  `CB_AUTHKEY` | Must be set to your CrossBrowserTesting account access key
427
436
  `CB_OS` | Refer to `os_api_name` capability in the sample script of the Wizard
428
437
  `CB_BROWSER` | Refer to `browser_api_name` capability in the sample script of the Wizard
429
- `RESOLUTION` | Refer to supported `screen_resolution` capability in the sample script of the Wizard
438
+ `RESOLUTION` | [Optional] Refer to supported `screen_resolution` capability in the sample script of the Wizard
439
+ `BROWSER_SIZE`| [Optional] Specify width, height of browser window
430
440
 
431
441
 
432
442
  #### Remote mobile browsers on the CrossBrowserTesting service
@@ -458,7 +468,8 @@ the table below. Use the Selenium API on the [Platform Configurator page](https:
458
468
  `SL_OS` | Refer to `platform` capability in the Copy Code section of the Platform Configurator page
459
469
  `SL_BROWSER` | Must be set to `chrome`, `firefox`, `safari`, `internet explorer`, or `edge`
460
470
  `SL_VERSION` | Refer to `version` capability in the Copy Code section of the Platform Configurator page
461
- `RESOLUTION` | Refer to supported `screenResolution` capability in the Copy Code section of the Platform Configurator page
471
+ `RESOLUTION` | [Optional] Refer to supported `screenResolution` capability in the Copy Code section of the Platform Configurator page
472
+ `BROWSER_SIZE`| [Optional] Specify width, height of browser window
462
473
 
463
474
 
464
475
  #### Remote mobile browsers on the Sauce Labs service
@@ -493,7 +504,8 @@ the table below. Refer to the [TestingBot List of Available Browsers page](https
493
504
  `TB_BROWSER` | Refer to `browserName` capability in chart
494
505
  `TB_VERSION` | Refer to `version` capability in chart
495
506
  `TUNNELING` | Must be `true` if you are testing against internal/local servers
496
- `RESOLUTION` | Possible values: `800x600`, `1024x768`, `1280x960`, `1280x1024`, `1600x1200`, `1920x1200`, `2560x1440`
507
+ `RESOLUTION` | [Optional] Possible values: `800x600`, `1024x768`, `1280x960`, `1280x1024`, `1600x1200`, `1920x1200`, `2560x1440`
508
+ `BROWSER_SIZE`| [Optional] Specify width, height of browser window
497
509
 
498
510
 
499
511
  ### Using Browser specific Profiles in cucumber.yml
@@ -506,7 +518,7 @@ Below is a list of Cucumber **Profiles** for supported locally and remotely host
506
518
  `cucumber.yml` file). Before you can use the BrowserStack, CrossBrowserTesting, Sauce Labs, or TestingBot services, you will need to
507
519
  replace the placeholder text with your user account and authorization code for the cloud service(s) that you intend to connect with.
508
520
 
509
- <% desktop = "--tags ~@wip --tags ~@failing --tags @desktop --require features" %>
521
+ <% desktop = "--tags ~@wip --tags ~@failing --tags @desktop --require features BROWSER_SIZE=1600,1000" %>
510
522
  <% mobile = "--tags ~@wip --tags ~@failing --tags @mobile --require features" %>
511
523
 
512
524
  #==============
@@ -6,9 +6,10 @@ module TestCentricity
6
6
  #
7
7
  # @param resolution [Array] the desired [width, height]
8
8
  # @example
9
- # Browsers.set_browser_window_size(1024, 768)
9
+ # Browsers.set_browser_window_size([1024, 768])
10
10
  #
11
11
  def self.set_browser_window_size(resolution)
12
+ resolution = resolution.split(',') if resolution.is_a?(String)
12
13
  window = Capybara.current_session.driver.browser.manage.window
13
14
  window.resize_to(resolution[0], resolution[1])
14
15
  end
@@ -95,7 +96,7 @@ module TestCentricity
95
96
  size = [width, height]
96
97
  end
97
98
  else
98
- size = [1900, 1000]
99
+ size = [1650, 1000]
99
100
  end
100
101
  size
101
102
  end
@@ -9,6 +9,17 @@ module TestCentricity
9
9
  @alt_locator = nil
10
10
  end
11
11
 
12
+ # Does checkbox object exists?
13
+ #
14
+ # @return [Boolean]
15
+ # @example
16
+ # remember_me_checkbox.exists?
17
+ #
18
+ def exists?
19
+ obj, _ = find_object(:all)
20
+ obj != nil
21
+ end
22
+
12
23
  # Is checkbox checked?
13
24
  #
14
25
  # @return [Boolean]
@@ -16,8 +27,7 @@ module TestCentricity
16
27
  # remember_me_checkbox.checked?
17
28
  #
18
29
  def checked?
19
- Capybara.ignore_hidden_elements = false
20
- obj, _ = find_element
30
+ obj, _ = find_element(:all)
21
31
  object_not_found_exception(obj, 'Checkbox')
22
32
  obj.checked?
23
33
  end
@@ -29,8 +39,7 @@ module TestCentricity
29
39
  # remember_me_checkbox.set_checkbox_state(true)
30
40
  #
31
41
  def set_checkbox_state(state)
32
- Capybara.ignore_hidden_elements = false
33
- obj, _ = find_element
42
+ obj, _ = find_element(:all)
34
43
  object_not_found_exception(obj, 'Checkbox')
35
44
  invalid_object_type_exception(obj, 'checkbox')
36
45
  begin
@@ -9,6 +9,17 @@ module TestCentricity
9
9
  @alt_locator = nil
10
10
  end
11
11
 
12
+ # Does radio button object exists?
13
+ #
14
+ # @return [Boolean]
15
+ # @example
16
+ # accept_terms_radio.exists?
17
+ #
18
+ def exists?
19
+ obj, _ = find_object(:all)
20
+ obj != nil
21
+ end
22
+
12
23
  # Is radio button selected?
13
24
  #
14
25
  # @return [Boolean]
@@ -16,8 +27,7 @@ module TestCentricity
16
27
  # accept_terms_radio.selected?
17
28
  #
18
29
  def selected?
19
- Capybara.ignore_hidden_elements = false
20
- obj, _ = find_element
30
+ obj, _ = find_element(:all)
21
31
  object_not_found_exception(obj, 'Radio')
22
32
  obj.checked?
23
33
  end
@@ -29,8 +39,7 @@ module TestCentricity
29
39
  # accept_terms_radio.set_selected_state(true)
30
40
  #
31
41
  def set_selected_state(state)
32
- Capybara.ignore_hidden_elements = false
33
- obj, _ = find_element
42
+ obj, _ = find_element(:all)
34
43
  object_not_found_exception(obj, 'Radio')
35
44
  invalid_object_type_exception(obj, 'radio')
36
45
  begin
@@ -27,6 +27,8 @@ module TestCentricity
27
27
  else
28
28
  first(:css, 'li.active-result', text: option).click
29
29
  end
30
+ elsif first(:xpath, "//ul/li")
31
+ first(:xpath, "//ul/li", text: option).click
30
32
  else
31
33
  if option.is_a?(Array)
32
34
  option.each do |item|
@@ -88,7 +90,7 @@ module TestCentricity
88
90
  def choose_siebel_option(option)
89
91
  Capybara.wait_on_first_by_default = true
90
92
  invoke_siebel_popup
91
- first(:xpath, "//li[@class='ui-menu-item']", :exact => true, :match => :prefer_exact,text: option).click
93
+ first(:xpath, "//li[@class='ui-menu-item']", :exact => true, :match => :prefer_exact, text: option).click
92
94
  end
93
95
 
94
96
  # Return array of strings of all options in a Siebel OUI select box object.
@@ -260,20 +260,16 @@ module TestCentricity
260
260
  def click_header_column(column)
261
261
  column_count = get_column_count
262
262
  raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{@locator}" if column > column_count
263
- (column > 1) ?
264
- set_alt_locator("#{@locator}/thead/tr/th[#{column}]") :
265
- set_alt_locator("#{@locator}/thead/tr/th")
266
- click
263
+ set_alt_locator("#{@locator}/thead/tr/th[#{column}]")
264
+ click if exists?
267
265
  clear_alt_locator
268
266
  end
269
267
 
270
268
  def get_header_column(column)
271
269
  column_count = get_column_count
272
270
  raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{@locator}" if column > column_count
273
- (column > 1) ?
274
- set_alt_locator("#{@locator}/thead/tr/th[#{column}]") :
275
- set_alt_locator("#{@locator}/thead/tr/th")
276
- value = get_value
271
+ set_alt_locator("#{@locator}/thead/tr/th[#{column}]")
272
+ value = get_value(:all) if exists?(:all)
277
273
  clear_alt_locator
278
274
  value
279
275
  end
@@ -282,10 +278,8 @@ module TestCentricity
282
278
  columns = []
283
279
  column_count = get_column_count
284
280
  (1..column_count).each do |column|
285
- (column > 1) ?
286
- set_alt_locator("#{@locator}/thead/tr/th[#{column}]") :
287
- set_alt_locator("#{@locator}/thead/tr/th")
288
- columns.push(get_value)
281
+ set_alt_locator("#{@locator}/thead/tr/th[#{column}]")
282
+ columns.push(get_value(:all)) if exists?(:all)
289
283
  end
290
284
  clear_alt_locator
291
285
  columns
@@ -262,6 +262,8 @@ module TestCentricity
262
262
  actual = ui_object.get_max_length
263
263
  when :options
264
264
  actual = ui_object.get_options
265
+ when :column_headers
266
+ actual = ui_object.get_header_columns
265
267
  when :siebel_options
266
268
  actual = ui_object.get_siebel_options
267
269
  else
@@ -278,6 +278,8 @@ module TestCentricity
278
278
  actual = ui_object.get_max_length
279
279
  when :options
280
280
  actual = ui_object.get_options
281
+ when :column_headers
282
+ actual = ui_object.get_header_columns
281
283
  when :siebel_options
282
284
  actual = ui_object.get_siebel_options
283
285
  else
@@ -335,6 +337,18 @@ module TestCentricity
335
337
  end
336
338
  end
337
339
 
340
+ def get_attribute(attrib)
341
+ section, _ = find_section
342
+ raise "Section #{locator} not found" unless section
343
+ section[attrib]
344
+ end
345
+
346
+ def get_native_attribute(attrib)
347
+ section, _ = find_section
348
+ raise "Section #{locator} not found" unless section
349
+ section.native.attribute(attrib)
350
+ end
351
+
338
352
  private
339
353
 
340
354
  def find_section
@@ -118,8 +118,8 @@ module TestCentricity
118
118
  # @example
119
119
  # basket_link.exists?
120
120
  #
121
- def exists?
122
- obj, _ = find_object
121
+ def exists?(visible = true)
122
+ obj, _ = find_object(visible)
123
123
  obj != nil
124
124
  end
125
125
 
@@ -240,8 +240,8 @@ module TestCentricity
240
240
  raise "Value of UI element #{@locator} failed to change from '#{value}' after #{timeout} seconds" unless exists?
241
241
  end
242
242
 
243
- def get_value
244
- obj, _ = find_element
243
+ def get_value(visible = true)
244
+ obj, _ = find_element(visible)
245
245
  object_not_found_exception(obj, nil)
246
246
  case obj.tag_name.downcase
247
247
  when 'input', 'select', 'textarea'
@@ -281,14 +281,26 @@ module TestCentricity
281
281
  obj.all(item_locator).collect(&:text)
282
282
  end
283
283
 
284
+ def get_attribute(attrib)
285
+ obj, _ = find_element
286
+ object_not_found_exception(obj, nil)
287
+ obj[attrib]
288
+ end
289
+
290
+ def get_native_attribute(attrib)
291
+ obj, _ = find_element
292
+ object_not_found_exception(obj, nil)
293
+ obj.native.attribute(attrib)
294
+ end
295
+
284
296
  private
285
297
 
286
- def find_element
298
+ def find_element(visible = true)
287
299
  wait = Selenium::WebDriver::Wait.new(timeout: Capybara.default_max_wait_time)
288
- wait.until { find_object }
300
+ wait.until { find_object(visible) }
289
301
  end
290
302
 
291
- def find_object
303
+ def find_object(visible = true)
292
304
  @alt_locator.nil? ? locator = @locator : locator = @alt_locator
293
305
  tries ||= 3
294
306
  attributes = [:name, :id, :xpath, :css]
@@ -298,23 +310,21 @@ module TestCentricity
298
310
  case type
299
311
  when :css
300
312
  parent_locator = parent_locator.gsub('|', ' ')
301
- obj = page.find(:css, parent_locator, :wait => 0.01).find(:css, locator, :wait => 0.01)
313
+ obj = page.find(:css, parent_locator, :wait => 0.01).find(:css, locator, :wait => 0.01, :visible => visible)
302
314
  when :xpath
303
315
  parent_locator = parent_locator.gsub('|', '')
304
- obj = page.find(:xpath, "#{parent_locator}#{locator}", :wait => 0.01)
316
+ obj = page.find(:xpath, "#{parent_locator}#{locator}", :wait => 0.01, :visible => visible)
305
317
  when :id
306
318
  parent_locator = parent_locator.gsub('|', ' ')
307
- obj = page.find(:css, parent_locator, :wait => 0.01).find(:xpath, locator, :wait => 0.01)
319
+ obj = page.find(:css, parent_locator, :wait => 0.01).find(:xpath, locator, :wait => 0.01, :visible => visible)
308
320
  end
309
321
  else
310
- obj = page.find(type, locator, :wait => 0.01)
322
+ obj = page.find(type, locator, :wait => 0.01, :visible => visible)
311
323
  end
312
324
  [obj, type]
313
325
  rescue
314
326
  retry if (tries -= 1) > 0
315
327
  [nil, nil]
316
- ensure
317
- Capybara.ignore_hidden_elements = true
318
328
  end
319
329
 
320
330
  def object_not_found_exception(obj, obj_type)
@@ -1,3 +1,3 @@
1
1
  module TestCentricityWeb
2
- VERSION = '0.7.4'
2
+ VERSION = '0.7.5'
3
3
  end
@@ -34,9 +34,13 @@ module TestCentricity
34
34
  # set browser window size only if testing with a desktop web browser
35
35
  unless Capybara.current_driver == :poltergeist
36
36
  if Environ.is_desktop?
37
- (ENV['BROWSER_SIZE'] == 'max') ?
38
- Browsers.maximize_browser :
39
- Browsers.set_browser_window_size(Browsers.browser_size(browser, ENV['ORIENTATION']))
37
+ if (ENV['BROWSER_SIZE'] == 'max') then
38
+ Browsers.maximize_browser
39
+ elsif ENV['BROWSER_SIZE']
40
+ Browsers.set_browser_window_size(ENV['BROWSER_SIZE'])
41
+ else
42
+ Browsers.set_browser_window_size(Browsers.browser_size(browser, ENV['ORIENTATION']))
43
+ end
40
44
  end
41
45
  end
42
46
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testcentricity_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - A.J. Mrozinski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-12 00:00:00.000000000 Z
11
+ date: 2016-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler