testcentricity 2.4.2 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) 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 -1380
  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 +343 -111
  56. data/lib/testcentricity/app_core/screen_object.rb +252 -0
  57. data/lib/testcentricity/app_core/screen_objects_helper.rb +29 -201
  58. data/lib/testcentricity/app_core/{screen_sections_helper.rb → screen_section.rb} +40 -105
  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/browser_helper.rb +0 -174
  94. data/lib/testcentricity/data_objects/data_objects_helper.rb +0 -78
  95. data/lib/testcentricity/data_objects/excel_helper.rb +0 -242
  96. data/lib/testcentricity/exception_queue_helper.rb +0 -111
  97. data/lib/testcentricity/utility_helpers.rb +0 -28
  98. data/lib/testcentricity/web_core/drag_drop_helper.rb +0 -15
  99. data/lib/testcentricity/web_core/page_objects_helper.rb +0 -677
  100. data/lib/testcentricity/web_core/page_sections_helper.rb +0 -895
  101. data/lib/testcentricity/web_core/webdriver_helper.rb +0 -588
  102. data/lib/testcentricity/web_elements/button.rb +0 -8
  103. data/lib/testcentricity/web_elements/cell_button.rb +0 -8
  104. data/lib/testcentricity/web_elements/cell_checkbox.rb +0 -38
  105. data/lib/testcentricity/web_elements/cell_element.rb +0 -69
  106. data/lib/testcentricity/web_elements/cell_image.rb +0 -8
  107. data/lib/testcentricity/web_elements/cell_radio.rb +0 -31
  108. data/lib/testcentricity/web_elements/checkbox.rb +0 -100
  109. data/lib/testcentricity/web_elements/file_field.rb +0 -45
  110. data/lib/testcentricity/web_elements/image.rb +0 -34
  111. data/lib/testcentricity/web_elements/label.rb +0 -8
  112. data/lib/testcentricity/web_elements/link.rb +0 -8
  113. data/lib/testcentricity/web_elements/list.rb +0 -100
  114. data/lib/testcentricity/web_elements/list_button.rb +0 -8
  115. data/lib/testcentricity/web_elements/list_checkbox.rb +0 -38
  116. data/lib/testcentricity/web_elements/list_element.rb +0 -61
  117. data/lib/testcentricity/web_elements/list_radio.rb +0 -31
  118. data/lib/testcentricity/web_elements/radio.rb +0 -74
  119. data/lib/testcentricity/web_elements/select_list.rb +0 -208
  120. data/lib/testcentricity/web_elements/siebel_open_ui_helper.rb +0 -15
  121. data/lib/testcentricity/web_elements/table.rb +0 -612
  122. data/lib/testcentricity/web_elements/textfield.rb +0 -114
  123. data/lib/testcentricity/web_elements/ui_elements_helper.rb +0 -532
  124. data/lib/testcentricity/world_extensions.rb +0 -26
  125. data/my_templates/default/method_details/setup.rb +0 -3
  126. data/spec/testcentricity_spec.rb +0 -9
@@ -1,69 +0,0 @@
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
@@ -1,8 +0,0 @@
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
@@ -1,31 +0,0 @@
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
@@ -1,100 +0,0 @@
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
@@ -1,45 +0,0 @@
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
@@ -1,34 +0,0 @@
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
@@ -1,8 +0,0 @@
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
@@ -1,8 +0,0 @@
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
@@ -1,100 +0,0 @@
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
-
73
- # Wait until the list's item_count equals the specified value, or until the specified wait time has expired. If the wait
74
- # time is nil, then the wait time will be Capybara.default_max_wait_time.
75
- #
76
- # @param value [Integer or Hash] value expected or comparison hash
77
- # @param seconds [Integer or Float] wait time in seconds
78
- # @example
79
- # search_results_list.wait_until_item_count_is(10, 15)
80
- # or
81
- # search_results_list.wait_until_item_count_is({ :greater_than_or_equal => 1 }, 5)
82
- #
83
- def wait_until_item_count_is(value, seconds = nil)
84
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
85
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
86
- wait.until { compare(value, get_item_count) }
87
- rescue
88
- raise "Value of List #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_item_count == value
89
- end
90
-
91
- def wait_until_item_count_changes(seconds = nil)
92
- value = get_item_count
93
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
94
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
95
- wait.until { get_item_count != value }
96
- rescue
97
- raise "Value of List #{object_ref_message} failed to change from '#{value}' after #{timeout} seconds" if get_item_count == value
98
- end
99
- end
100
- end
@@ -1,8 +0,0 @@
1
- module TestCentricity
2
- class ListButton < ListElement
3
- def initialize(name, parent, locator, context, list, proxy = nil)
4
- super
5
- @type = :list_button
6
- end
7
- end
8
- end
@@ -1,38 +0,0 @@
1
- module TestCentricity
2
- class ListCheckBox < ListElement
3
- attr_accessor :proxy
4
-
5
- def initialize(name, parent, locator, context, list, proxy = nil)
6
- super
7
- @type = :list_checkbox
8
- @proxy = proxy
9
- end
10
-
11
- def checked?(row)
12
- obj, = find_list_element(row)
13
- list_object_not_found_exception(obj, 'List CheckBox', row)
14
- obj.checked?
15
- end
16
-
17
- def set_checkbox_state(row, state)
18
- obj, = find_list_element(row)
19
- list_object_not_found_exception(obj, 'List 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} List Checkbox #{object_ref_message}") :
35
- assert_equal(state, actual, "Expected Row #{row} List Checkbox #{object_ref_message} to be #{state} but found #{actual} instead")
36
- end
37
- end
38
- end
@@ -1,61 +0,0 @@
1
- module TestCentricity
2
- class ListElement < UIElement
3
- attr_accessor :list
4
- attr_accessor :element_locator
5
-
6
- def initialize(name, parent, locator, context, list, proxy = nil)
7
- @name = name
8
- @parent = parent
9
- @context = context
10
- @alt_locator = nil
11
- @list = list
12
- @element_locator = locator
13
-
14
- set_locator_type(@list.get_locator)
15
-
16
- if locator.nil?
17
- @locator = list.get_list_row_locator('ROW_SPEC')
18
- else
19
- case @locator_type
20
- when :xpath
21
- @locator = "#{list.get_list_row_locator('ROW_SPEC')}/#{@element_locator}"
22
- when :css
23
- @locator = "#{list.get_list_row_locator('ROW_SPEC')} > #{@element_locator}"
24
- end
25
- end
26
- end
27
-
28
- def exists?(row)
29
- obj, = find_list_element(row)
30
- obj != nil
31
- end
32
-
33
- def click(row)
34
- obj, = find_list_element(row)
35
- list_object_not_found_exception(obj, @type, row)
36
- obj.click
37
- end
38
-
39
- def get_value(row, visible = true)
40
- obj, = find_list_element(row, visible)
41
- list_object_not_found_exception(obj, @type, row)
42
- case obj.tag_name.downcase
43
- when 'input', 'select', 'textarea'
44
- obj.value
45
- else
46
- obj.text
47
- end
48
- end
49
-
50
- alias get_caption get_value
51
-
52
- def find_list_element(row, visible = true)
53
- set_alt_locator("#{@locator.gsub('ROW_SPEC', row.to_s)}")
54
- find_element(visible)
55
- end
56
-
57
- def list_object_not_found_exception(obj, obj_type, row)
58
- object_not_found_exception(obj, "Row #{row} #{obj_type}")
59
- end
60
- end
61
- end
@@ -1,31 +0,0 @@
1
- module TestCentricity
2
- class ListRadio < ListElement
3
- attr_accessor :proxy
4
-
5
- def initialize(name, parent, locator, context, list, proxy = nil)
6
- super
7
- @type = :list_radio
8
- @proxy = proxy
9
- end
10
-
11
- def selected?(row)
12
- obj, = find_list_element(row)
13
- list_object_not_found_exception(obj, 'List Radio', row)
14
- obj.checked?
15
- end
16
-
17
- def set_selected_state(row, state)
18
- obj, = find_list_element(row)
19
- list_object_not_found_exception(obj, 'List 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
@@ -1,74 +0,0 @@
1
- module TestCentricity
2
- class Radio < 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 = :radio
13
- set_locator_type
14
- end
15
-
16
- # Does radio button object exists?
17
- #
18
- # @return [Boolean]
19
- # @example
20
- # accept_terms_radio.exists?
21
- #
22
- def exists?
23
- obj, = find_object(:all)
24
- obj != nil
25
- end
26
-
27
- # Is radio button selected?
28
- #
29
- # @return [Boolean]
30
- # @example
31
- # accept_terms_radio.selected?
32
- #
33
- def selected?
34
- obj, = find_element(:all)
35
- object_not_found_exception(obj, 'Radio')
36
- obj.checked?
37
- end
38
-
39
- # Set the select state of a radio button object.
40
- #
41
- # @param state [Boolean] true = selected / false = unselected
42
- # @example
43
- # accept_terms_radio.set_selected_state(true)
44
- #
45
- def set_selected_state(state)
46
- obj, = find_element(:all)
47
- object_not_found_exception(obj, 'Radio')
48
- invalid_object_type_exception(obj, 'radio')
49
- if @proxy.nil?
50
- obj.set(state)
51
- else
52
- @proxy.click unless state == obj.checked?
53
- end
54
- end
55
-
56
- # Set the selected state of a radio button object.
57
- #
58
- # @example
59
- # accept_terms_radio.select
60
- #
61
- def select
62
- set_selected_state(true)
63
- end
64
-
65
- # Unselect a radio button object.
66
- #
67
- # @example
68
- # accept_terms_radio.unselect
69
- #
70
- def unselect
71
- set_selected_state(false)
72
- end
73
- end
74
- end