testcentricity_web 2.1.8.2 → 2.1.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +27 -0
  3. data/.rubocop.yml +41 -0
  4. data/.yardopts +2 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE.txt +28 -0
  7. data/README.md +1438 -0
  8. data/Rakefile +1 -0
  9. data/lib/devices/devices.yml +280 -0
  10. data/lib/testcentricity_web.rb +140 -0
  11. data/lib/testcentricity_web/browser_helper.rb +173 -0
  12. data/lib/testcentricity_web/data_objects_helper.rb +78 -0
  13. data/lib/testcentricity_web/drag_drop_helper.rb +15 -0
  14. data/lib/testcentricity_web/elements/button.rb +8 -0
  15. data/lib/testcentricity_web/elements/cell_button.rb +8 -0
  16. data/lib/testcentricity_web/elements/cell_checkbox.rb +38 -0
  17. data/lib/testcentricity_web/elements/cell_element.rb +62 -0
  18. data/lib/testcentricity_web/elements/cell_image.rb +8 -0
  19. data/lib/testcentricity_web/elements/cell_radio.rb +31 -0
  20. data/lib/testcentricity_web/elements/checkbox.rb +99 -0
  21. data/lib/testcentricity_web/elements/file_field.rb +45 -0
  22. data/lib/testcentricity_web/elements/image.rb +34 -0
  23. data/lib/testcentricity_web/elements/label.rb +8 -0
  24. data/lib/testcentricity_web/elements/link.rb +8 -0
  25. data/lib/testcentricity_web/elements/list.rb +54 -0
  26. data/lib/testcentricity_web/elements/list_button.rb +8 -0
  27. data/lib/testcentricity_web/elements/list_checkbox.rb +38 -0
  28. data/lib/testcentricity_web/elements/list_element.rb +51 -0
  29. data/lib/testcentricity_web/elements/list_radio.rb +31 -0
  30. data/lib/testcentricity_web/elements/radio.rb +73 -0
  31. data/lib/testcentricity_web/elements/select_list.rb +189 -0
  32. data/lib/testcentricity_web/elements/table.rb +473 -0
  33. data/lib/testcentricity_web/elements/textfield.rb +84 -0
  34. data/lib/testcentricity_web/environment.rb +249 -0
  35. data/lib/testcentricity_web/excel_helper.rb +242 -0
  36. data/lib/testcentricity_web/exception_queue_helper.rb +47 -0
  37. data/lib/testcentricity_web/page_objects_helper.rb +656 -0
  38. data/lib/testcentricity_web/page_sections_helper.rb +811 -0
  39. data/lib/testcentricity_web/siebel_open_ui_helper.rb +15 -0
  40. data/lib/testcentricity_web/ui_elements_helper.rb +425 -0
  41. data/lib/testcentricity_web/utility_helpers.rb +28 -0
  42. data/lib/testcentricity_web/version.rb +3 -0
  43. data/lib/testcentricity_web/webdriver_helper.rb +451 -0
  44. data/lib/testcentricity_web/world_extensions.rb +26 -0
  45. data/testcentricity_web.gemspec +42 -0
  46. metadata +52 -4
@@ -0,0 +1,78 @@
1
+ require 'yaml'
2
+ require 'json'
3
+
4
+
5
+ module TestCentricity
6
+
7
+ XL_PRIMARY_DATA_PATH ||= 'features/test_data/'
8
+ XL_PRIMARY_DATA_FILE ||= "#{XL_PRIMARY_DATA_PATH}data.xls"
9
+
10
+
11
+ class DataObject
12
+ attr_accessor :current
13
+ attr_accessor :context
14
+ attr_accessor :hash_table
15
+
16
+ def initialize(data)
17
+ @hash_table = data
18
+ end
19
+
20
+ # @deprecated Please use {#current=} instead
21
+ def self.set_current(current)
22
+ warn "[DEPRECATION] 'TestCentricity::DataObject.set_current' is deprecated. Please use 'current=' instead."
23
+ @current = current
24
+ end
25
+
26
+ def self.current
27
+ @current
28
+ end
29
+
30
+ def self.current=(current)
31
+ @current = current
32
+ end
33
+ end
34
+
35
+
36
+ class DataSource
37
+ attr_accessor :current
38
+
39
+ def read_yaml_node_data(file_name, node_name)
40
+ data = YAML.load_file("#{XL_PRIMARY_DATA_PATH}#{file_name}")
41
+ data[node_name]
42
+ end
43
+
44
+ def read_json_node_data(file_name, node_name)
45
+ raw_data = File.read("#{XL_PRIMARY_DATA_PATH}#{file_name}")
46
+ data = JSON.parse(raw_data)
47
+ data[node_name]
48
+ end
49
+ end
50
+
51
+
52
+ class ExcelDataSource < TestCentricity::DataSource
53
+ def pick_excel_data_source(sheet, row_spec)
54
+ if ENV['TEST_ENVIRONMENT']
55
+ environment = ENV['TEST_ENVIRONMENT']
56
+ data_file = "#{XL_PRIMARY_DATA_PATH}#{environment}_data.xls"
57
+ data_file = XL_PRIMARY_DATA_FILE unless ExcelData.rowspec_exists?(data_file, sheet, row_spec)
58
+ else
59
+ data_file = XL_PRIMARY_DATA_FILE
60
+ end
61
+ data_file
62
+ end
63
+
64
+ def read_excel_row_data(sheet, row_name, parallel = false)
65
+ parallel == :parallel && ENV['PARALLEL'] ? row_spec = "#{row_name}#{ENV['TEST_ENV_NUMBER']}" : row_spec = row_name
66
+ ExcelData.read_row_data(pick_excel_data_source(sheet, row_spec), sheet, row_spec)
67
+ end
68
+
69
+ def read_excel_pool_data(sheet, row_name, parallel = false)
70
+ parallel == :parallel && ENV['PARALLEL'] ? row_spec = "#{row_name}#{ENV['TEST_ENV_NUMBER']}" : row_spec = row_name
71
+ ExcelData.read_row_from_pool(pick_excel_data_source(sheet, row_name), sheet, row_spec)
72
+ end
73
+
74
+ def read_excel_range_data(sheet, range_name)
75
+ ExcelData.read_range_data(pick_excel_data_source(sheet, range_name), sheet, range_name)
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,15 @@
1
+ module CapybaraExtension
2
+ def drag_by(right_by, down_by)
3
+ base.drag_by(right_by, down_by)
4
+ end
5
+ end
6
+
7
+
8
+ module CapybaraSeleniumExtension
9
+ def drag_by(right_by, down_by)
10
+ driver.browser.action.drag_and_drop_by(native, right_by, down_by).perform
11
+ end
12
+ end
13
+
14
+ ::Capybara::Selenium::Node.send :include, CapybaraSeleniumExtension
15
+ ::Capybara::Node::Element.send :include, CapybaraExtension
@@ -0,0 +1,8 @@
1
+ module TestCentricity
2
+ class Button < UIElement
3
+ def initialize(name, parent, locator, context)
4
+ super
5
+ @type = :button
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module TestCentricity
2
+ class CellButton < CellElement
3
+ def initialize(name, parent, locator, context, table, column, proxy = nil)
4
+ super
5
+ @type = :cell_button
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,38 @@
1
+ module TestCentricity
2
+ class CellCheckBox < CellElement
3
+ attr_accessor :proxy
4
+
5
+ def initialize(name, parent, locator, context, table, column, proxy = nil)
6
+ super
7
+ @type = :cell_checkbox
8
+ @proxy = proxy
9
+ end
10
+
11
+ def checked?(row)
12
+ obj, = find_cell_element(row)
13
+ cell_object_not_found_exception(obj, 'Cell CheckBox', row)
14
+ obj.checked?
15
+ end
16
+
17
+ def set_checkbox_state(row, state)
18
+ obj, = find_cell_element(row)
19
+ cell_object_not_found_exception(obj, 'Cell CheckBox', row)
20
+ obj.set(state)
21
+ end
22
+
23
+ def check(row)
24
+ set_checkbox_state(row, true)
25
+ end
26
+
27
+ def uncheck(row)
28
+ set_checkbox_state(row, false)
29
+ end
30
+
31
+ def verify_check_state(row, state, enqueue = false)
32
+ actual = checked?(row)
33
+ enqueue ?
34
+ ExceptionQueue.enqueue_assert_equal(state, actual, "Expected Row #{row}/Col #{@column} Cell Checkbox #{object_ref_message}") :
35
+ assert_equal(state, actual, "Expected Row #{row}/Col #{@column} Cell Checkbox #{object_ref_message} to be #{state} but found #{actual} instead")
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,62 @@
1
+ module TestCentricity
2
+ class CellElement < UIElement
3
+ attr_accessor :table
4
+ attr_accessor :column
5
+ attr_accessor :element_locator
6
+
7
+ def initialize(name, parent, locator, context, table, column, proxy = nil)
8
+ @name = name
9
+ @parent = parent
10
+ @context = context
11
+ @alt_locator = nil
12
+ @table = table
13
+ @column = column
14
+ @element_locator = locator
15
+ @locator = "#{@table.get_table_cell_locator('ROW_SPEC', @column)}/#{@element_locator}"
16
+ end
17
+
18
+ def set_column(column)
19
+ @column = column
20
+ @locator = "#{@table.get_table_cell_locator('ROW_SPEC', @column)}/#{@element_locator}"
21
+ end
22
+
23
+ def exists?(row)
24
+ obj, = find_cell_element(row)
25
+ obj != nil
26
+ end
27
+
28
+ def click(row)
29
+ obj, = find_cell_element(row)
30
+ cell_object_not_found_exception(obj, @type, row)
31
+ obj.click
32
+ end
33
+
34
+ def get_native_attribute(row, attrib)
35
+ obj, = find_cell_element(row)
36
+ cell_object_not_found_exception(obj, @type, row)
37
+ obj.get_native_attribute(attrib)
38
+ end
39
+
40
+ def get_value(row, visible = true)
41
+ obj, = find_cell_element(row, visible)
42
+ cell_object_not_found_exception(obj, @type, row)
43
+ case obj.tag_name.downcase
44
+ when 'input', 'select', 'textarea'
45
+ obj.value
46
+ else
47
+ obj.text
48
+ end
49
+ end
50
+
51
+ alias get_caption get_value
52
+
53
+ def find_cell_element(row, visible = true)
54
+ set_alt_locator("#{@locator.gsub('ROW_SPEC', row.to_s)}")
55
+ find_element(visible)
56
+ end
57
+
58
+ def cell_object_not_found_exception(obj, obj_type, row)
59
+ object_not_found_exception(obj, "Row #{row}/Col #{@column} #{obj_type}")
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,8 @@
1
+ module TestCentricity
2
+ class CellImage < CellElement
3
+ def initialize(name, parent, locator, context, table, column, proxy = nil)
4
+ super
5
+ @type = :cell_image
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,31 @@
1
+ module TestCentricity
2
+ class CellRadio < CellElement
3
+ attr_accessor :proxy
4
+
5
+ def initialize(name, parent, locator, context, table, column, proxy = nil)
6
+ super
7
+ @type = :cell_radio
8
+ @proxy = proxy
9
+ end
10
+
11
+ def selected?(row)
12
+ obj, = find_cell_element(row)
13
+ cell_object_not_found_exception(obj, 'Cell Radio', row)
14
+ obj.checked?
15
+ end
16
+
17
+ def set_selected_state(row, state)
18
+ obj, = find_cell_element(row)
19
+ cell_object_not_found_exception(obj, 'Cell Radio', row)
20
+ obj.set(state)
21
+ end
22
+
23
+ def select(row)
24
+ set_selected_state(row, true)
25
+ end
26
+
27
+ def unselect(row)
28
+ set_selected_state(row, false)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,99 @@
1
+ module TestCentricity
2
+ class CheckBox < UIElement
3
+ attr_accessor :proxy
4
+
5
+ def initialize(name, parent, locator, context, proxy = nil)
6
+ @name = name
7
+ @parent = parent
8
+ @locator = locator
9
+ @context = context
10
+ @alt_locator = nil
11
+ @proxy = proxy
12
+ @type = :checkbox
13
+ end
14
+
15
+ # Does checkbox object exists?
16
+ #
17
+ # @return [Boolean]
18
+ # @example
19
+ # remember_me_checkbox.exists?
20
+ #
21
+ def exists?
22
+ obj, = find_object(:all)
23
+ obj != nil
24
+ end
25
+
26
+ # Is checkbox checked?
27
+ #
28
+ # @return [Boolean]
29
+ # @example
30
+ # remember_me_checkbox.checked?
31
+ #
32
+ def checked?
33
+ obj, = find_element(:all)
34
+ object_not_found_exception(obj, 'Checkbox')
35
+ obj.checked?
36
+ end
37
+
38
+ # Set the check state of a checkbox object.
39
+ #
40
+ # @param state [Boolean] true = checked / false = unchecked
41
+ # @example
42
+ # remember_me_checkbox.set_checkbox_state(true)
43
+ #
44
+ def set_checkbox_state(state)
45
+ obj, = find_element(:all)
46
+ object_not_found_exception(obj, 'Checkbox')
47
+ invalid_object_type_exception(obj, 'checkbox')
48
+ if @proxy.nil?
49
+ if obj.native.attribute('ot') == 'JCheckBox'
50
+ expected = state.to_bool
51
+ obj.click unless expected == obj.checked?
52
+ else
53
+ obj.set(state)
54
+ end
55
+ else
56
+ @proxy.click unless state == obj.checked?
57
+ end
58
+ end
59
+
60
+ # Set the check state of a checkbox object.
61
+ #
62
+ # @example
63
+ # remember_me_checkbox.check
64
+ #
65
+ def check
66
+ set_checkbox_state(true)
67
+ end
68
+
69
+ # Uncheck a checkbox object.
70
+ #
71
+ # @example
72
+ # remember_me_checkbox.uncheck
73
+ #
74
+ def uncheck
75
+ set_checkbox_state(false)
76
+ end
77
+
78
+ def verify_check_state(state, enqueue = false)
79
+ actual = checked?
80
+ enqueue ?
81
+ ExceptionQueue.enqueue_assert_equal(state, actual, "Expected checkbox #{object_ref_message}") :
82
+ assert_equal(state, actual, "Expected checkbox #{object_ref_message} to be #{state} but found #{actual} instead")
83
+ end
84
+
85
+ # Set the check state of a Siebel OUI JCheckBox object.
86
+ #
87
+ # @param state [Boolean] true = checked / false = unchecked
88
+ # @example
89
+ # remember_me_checkbox.set_siebel_checkbox_state(true)
90
+ #
91
+ def set_siebel_checkbox_state(state)
92
+ obj, = find_element
93
+ object_not_found_exception(obj, 'Siebel checkbox')
94
+ raise "UI #{object_ref_message} is not a Siebel CheckBox object" unless get_siebel_object_type == 'JCheckBox'
95
+ expected = state.to_bool
96
+ obj.click unless expected == obj.checked?
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,45 @@
1
+ module TestCentricity
2
+ class FileField < UIElement
3
+ def initialize(name, parent, locator, context)
4
+ super
5
+ @type = :filefield
6
+ end
7
+
8
+ def file_attach(file_path)
9
+ Capybara.ignore_hidden_elements = false
10
+ page.attach_file(@locator, file_path)
11
+ Capybara.ignore_hidden_elements = true
12
+ end
13
+
14
+ def file_upload(file_path)
15
+ obj, = find_element(false)
16
+ obj.send_keys(file_path)
17
+ end
18
+
19
+ def drop_files(files)
20
+ js_script = 'fileList = Array();'
21
+ files.count.times do |i|
22
+ # generate a fake input selector
23
+ page.execute_script("if ($('#seleniumUpload#{i}').length == 0) { seleniumUpload#{i} = window.$('<input/>').attr({id: 'seleniumUpload#{i}', type:'file'}).appendTo('body'); }")
24
+ # attach file to the fake input selector through Capybara
25
+ attach_file("seleniumUpload#{i}", files[i])
26
+ # create the fake js event
27
+ js_script = "#{js_script} fileList.push(seleniumUpload#{i}.get(0).files[0]);"
28
+ end
29
+ # trigger the fake drop event
30
+ page.execute_script("#{js_script} e = $.Event('drop'); e.originalEvent = {dataTransfer : { files : fileList } }; $('#{@locator}').trigger(e);")
31
+ end
32
+
33
+ def ng_drop_file(file_path)
34
+ # generate a fake input selector
35
+ page.execute_script("fakeFileInput = window.$('<input/>').attr({ id: 'fileFileInput', type: 'file' }).appendTo('body');")
36
+ # attach file to the fake input selector through Capybara
37
+ page.attach_file('fakeFileInput', file_path)
38
+ # create the fake js event
39
+ js_script = "var scope = angular.element('#{@locator}').scope();"
40
+ js_script = "#{js_script} scope.files = [fakeFileInput.get(0).files[0]];"
41
+ # trigger the fake drop event
42
+ page.execute_script(js_script)
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,34 @@
1
+ module TestCentricity
2
+ class Image < UIElement
3
+ def initialize(name, parent, locator, context)
4
+ super
5
+ @type = :image
6
+ end
7
+
8
+ # Is image loaded?
9
+ #
10
+ # @return [Boolean]
11
+ # @example
12
+ # company_logo_image.is_loaded??
13
+ #
14
+ def is_loaded?
15
+ obj, = find_element
16
+ object_not_found_exception(obj, nil)
17
+ obj.native.attribute('complete')
18
+ end
19
+
20
+ # Wait until the image is fully loaded, or until the specified wait time has expired.
21
+ #
22
+ # @param seconds [Integer or Float] wait time in seconds
23
+ # @example
24
+ # company_logo_image.wait_until_loaded(5)
25
+ #
26
+ def wait_until_loaded(seconds = nil)
27
+ timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
28
+ wait = Selenium::WebDriver::Wait.new(timeout: timeout)
29
+ wait.until { is_loaded? }
30
+ rescue
31
+ raise "Image #{object_ref_message} failed to load within #{timeout} seconds" unless is_loaded?
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,8 @@
1
+ module TestCentricity
2
+ class Label < UIElement
3
+ def initialize(name, parent, locator, context)
4
+ super
5
+ @type = :label
6
+ end
7
+ end
8
+ end