testcentricity 2.3.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.lock +93 -0
  8. data/LICENSE.txt +28 -0
  9. data/README.md +1634 -0
  10. data/Rakefile +1 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/lib/devices/devices.yml +344 -0
  14. data/lib/testcentricity.rb +144 -0
  15. data/lib/testcentricity/app_core/appium_connect_helper.rb +154 -0
  16. data/lib/testcentricity/app_core/appium_server.rb +69 -0
  17. data/lib/testcentricity/app_core/screen_objects_helper.rb +180 -0
  18. data/lib/testcentricity/app_core/screen_sections_helper.rb +332 -0
  19. data/lib/testcentricity/app_elements/app_element_helper.rb +293 -0
  20. data/lib/testcentricity/app_elements/button.rb +8 -0
  21. data/lib/testcentricity/app_elements/checkbox.rb +20 -0
  22. data/lib/testcentricity/app_elements/label.rb +8 -0
  23. data/lib/testcentricity/app_elements/list.rb +25 -0
  24. data/lib/testcentricity/app_elements/switch.rb +20 -0
  25. data/lib/testcentricity/app_elements/textfield.rb +12 -0
  26. data/lib/testcentricity/browser_helper.rb +174 -0
  27. data/lib/testcentricity/data_objects/data_objects_helper.rb +78 -0
  28. data/lib/testcentricity/data_objects/environment.rb +281 -0
  29. data/lib/testcentricity/data_objects/excel_helper.rb +242 -0
  30. data/lib/testcentricity/exception_queue_helper.rb +51 -0
  31. data/lib/testcentricity/utility_helpers.rb +28 -0
  32. data/lib/testcentricity/version.rb +3 -0
  33. data/lib/testcentricity/web_core/drag_drop_helper.rb +15 -0
  34. data/lib/testcentricity/web_core/page_objects_helper.rb +669 -0
  35. data/lib/testcentricity/web_core/page_sections_helper.rb +866 -0
  36. data/lib/testcentricity/web_core/webdriver_helper.rb +579 -0
  37. data/lib/testcentricity/web_elements/button.rb +8 -0
  38. data/lib/testcentricity/web_elements/cell_button.rb +8 -0
  39. data/lib/testcentricity/web_elements/cell_checkbox.rb +38 -0
  40. data/lib/testcentricity/web_elements/cell_element.rb +69 -0
  41. data/lib/testcentricity/web_elements/cell_image.rb +8 -0
  42. data/lib/testcentricity/web_elements/cell_radio.rb +31 -0
  43. data/lib/testcentricity/web_elements/checkbox.rb +100 -0
  44. data/lib/testcentricity/web_elements/file_field.rb +45 -0
  45. data/lib/testcentricity/web_elements/image.rb +34 -0
  46. data/lib/testcentricity/web_elements/label.rb +8 -0
  47. data/lib/testcentricity/web_elements/link.rb +8 -0
  48. data/lib/testcentricity/web_elements/list.rb +73 -0
  49. data/lib/testcentricity/web_elements/list_button.rb +8 -0
  50. data/lib/testcentricity/web_elements/list_checkbox.rb +38 -0
  51. data/lib/testcentricity/web_elements/list_element.rb +61 -0
  52. data/lib/testcentricity/web_elements/list_radio.rb +31 -0
  53. data/lib/testcentricity/web_elements/radio.rb +74 -0
  54. data/lib/testcentricity/web_elements/select_list.rb +197 -0
  55. data/lib/testcentricity/web_elements/siebel_open_ui_helper.rb +15 -0
  56. data/lib/testcentricity/web_elements/table.rb +612 -0
  57. data/lib/testcentricity/web_elements/textfield.rb +114 -0
  58. data/lib/testcentricity/web_elements/ui_elements_helper.rb +502 -0
  59. data/lib/testcentricity/world_extensions.rb +26 -0
  60. data/my_templates/default/method_details/setup.rb +3 -0
  61. data/spec/spec_helper.rb +14 -0
  62. data/spec/testcentricity_spec.rb +9 -0
  63. data/testcentricity.gemspec +47 -0
  64. metadata +328 -0
@@ -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,69 @@
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
+
16
+ set_locator_type(@table.get_locator)
17
+ set_column(column)
18
+ end
19
+
20
+ def set_column(column)
21
+ @column = column
22
+ case @locator_type
23
+ when :xpath
24
+ @locator = "#{@table.get_table_cell_locator('ROW_SPEC', @column)}/#{@element_locator}"
25
+ when :css
26
+ @locator = "#{@table.get_table_cell_locator('ROW_SPEC', @column)} > #{@element_locator}"
27
+ end
28
+ end
29
+
30
+ def exists?(row)
31
+ obj, = find_cell_element(row)
32
+ obj != nil
33
+ end
34
+
35
+ def click(row)
36
+ obj, = find_cell_element(row)
37
+ cell_object_not_found_exception(obj, @type, row)
38
+ obj.click
39
+ end
40
+
41
+ def get_native_attribute(row, attrib)
42
+ obj, = find_cell_element(row)
43
+ cell_object_not_found_exception(obj, @type, row)
44
+ obj.get_native_attribute(attrib)
45
+ end
46
+
47
+ def get_value(row, visible = true)
48
+ obj, = find_cell_element(row, visible)
49
+ cell_object_not_found_exception(obj, @type, row)
50
+ case obj.tag_name.downcase
51
+ when 'input', 'select', 'textarea'
52
+ obj.value
53
+ else
54
+ obj.text
55
+ end
56
+ end
57
+
58
+ alias get_caption get_value
59
+
60
+ def find_cell_element(row, visible = true)
61
+ set_alt_locator("#{@locator.gsub('ROW_SPEC', row.to_s)}")
62
+ find_element(visible)
63
+ end
64
+
65
+ def cell_object_not_found_exception(obj, obj_type, row)
66
+ object_not_found_exception(obj, "Row #{row}/Col #{@column} #{obj_type}")
67
+ end
68
+ end
69
+ 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,100 @@
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
+ set_locator_type
14
+ end
15
+
16
+ # Does checkbox object exists?
17
+ #
18
+ # @return [Boolean]
19
+ # @example
20
+ # remember_me_checkbox.exists?
21
+ #
22
+ def exists?
23
+ obj, = find_object(:all)
24
+ obj != nil
25
+ end
26
+
27
+ # Is checkbox checked?
28
+ #
29
+ # @return [Boolean]
30
+ # @example
31
+ # remember_me_checkbox.checked?
32
+ #
33
+ def checked?
34
+ obj, = find_element(:all)
35
+ object_not_found_exception(obj, 'Checkbox')
36
+ obj.checked?
37
+ end
38
+
39
+ # Set the check state of a checkbox object.
40
+ #
41
+ # @param state [Boolean] true = checked / false = unchecked
42
+ # @example
43
+ # remember_me_checkbox.set_checkbox_state(true)
44
+ #
45
+ def set_checkbox_state(state)
46
+ obj, = find_element(:all)
47
+ object_not_found_exception(obj, 'Checkbox')
48
+ invalid_object_type_exception(obj, 'checkbox')
49
+ if @proxy.nil?
50
+ if obj.native.attribute('ot') == 'JCheckBox'
51
+ expected = state.to_bool
52
+ obj.click unless expected == obj.checked?
53
+ else
54
+ obj.set(state)
55
+ end
56
+ else
57
+ @proxy.click unless state == obj.checked?
58
+ end
59
+ end
60
+
61
+ # Set the check state of a checkbox object.
62
+ #
63
+ # @example
64
+ # remember_me_checkbox.check
65
+ #
66
+ def check
67
+ set_checkbox_state(true)
68
+ end
69
+
70
+ # Uncheck a checkbox object.
71
+ #
72
+ # @example
73
+ # remember_me_checkbox.uncheck
74
+ #
75
+ def uncheck
76
+ set_checkbox_state(false)
77
+ end
78
+
79
+ def verify_check_state(state, enqueue = false)
80
+ actual = checked?
81
+ enqueue ?
82
+ ExceptionQueue.enqueue_assert_equal(state, actual, "Expected checkbox #{object_ref_message}") :
83
+ assert_equal(state, actual, "Expected checkbox #{object_ref_message} to be #{state} but found #{actual} instead")
84
+ end
85
+
86
+ # Set the check state of a Siebel OUI JCheckBox object.
87
+ #
88
+ # @param state [Boolean] true = checked / false = unchecked
89
+ # @example
90
+ # remember_me_checkbox.set_siebel_checkbox_state(true)
91
+ #
92
+ def set_siebel_checkbox_state(state)
93
+ obj, = find_element
94
+ object_not_found_exception(obj, 'Siebel checkbox')
95
+ raise "UI #{object_ref_message} is not a Siebel CheckBox object" unless get_siebel_object_type == 'JCheckBox'
96
+ expected = state.to_bool
97
+ obj.click unless expected == obj.checked?
98
+ end
99
+ end
100
+ 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
@@ -0,0 +1,8 @@
1
+ module TestCentricity
2
+ class Link < UIElement
3
+ def initialize(name, parent, locator, context)
4
+ super
5
+ @type = :link
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,73 @@
1
+ module TestCentricity
2
+ class List < UIElement
3
+ attr_accessor :list_item
4
+
5
+ def initialize(name, parent, locator, context)
6
+ super
7
+ @type = :list
8
+ define_list_elements({ :list_item => 'li' })
9
+ end
10
+
11
+ def define_list_elements(element_spec)
12
+ element_spec.each do |element, value|
13
+ case element
14
+ when :list_item
15
+ @list_item = value
16
+ else
17
+ raise "#{element} is not a recognized list element"
18
+ end
19
+ end
20
+ end
21
+
22
+ def get_list_items(element_spec = nil)
23
+ define_list_elements(element_spec) unless element_spec.nil?
24
+ obj, = find_element
25
+ object_not_found_exception(obj, nil)
26
+ obj.all(@list_item).collect(&:text)
27
+ end
28
+
29
+ def get_list_item(index, visible = true)
30
+ if visible
31
+ items = get_list_items
32
+ else
33
+ items = get_all_list_items
34
+ end
35
+ items[index - 1]
36
+ end
37
+
38
+ def get_item_count
39
+ obj, = find_element
40
+ object_not_found_exception(obj, nil)
41
+ obj.all(@list_item).count
42
+ end
43
+
44
+ def get_all_list_items(element_spec = nil)
45
+ define_list_elements(element_spec) unless element_spec.nil?
46
+ obj, = find_element
47
+ object_not_found_exception(obj, nil)
48
+ obj.all(@list_item, :visible => :all).collect(&:text)
49
+ end
50
+
51
+ def get_all_items_count
52
+ obj, = find_element
53
+ object_not_found_exception(obj, nil)
54
+ obj.all(@list_item, :visible => :all).count
55
+ end
56
+
57
+ def verify_list_items(expected, enqueue = false)
58
+ actual = get_list_items
59
+ enqueue ?
60
+ ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected list #{object_ref_message}") :
61
+ assert_equal(expected, actual, "Expected list #{object_ref_message} to be #{expected} but found #{actual}")
62
+ end
63
+
64
+ def get_list_row_locator(row)
65
+ case @locator_type
66
+ when :xpath
67
+ "#{@locator}/#{@list_item}[#{row}]"
68
+ when :css
69
+ "#{@locator} > #{@list_item}:nth-of-type(#{row})"
70
+ end
71
+ end
72
+ end
73
+ end