testcentricity_web 4.3.1 → 4.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -12
  3. data/LICENSE.md +1 -1
  4. data/README.md +1794 -697
  5. data/lib/devices/devices.yml +144 -216
  6. data/lib/testcentricity_web/browser_helper.rb +33 -4
  7. data/lib/testcentricity_web/data_objects/environment.rb +96 -13
  8. data/lib/testcentricity_web/exception_queue_helper.rb +5 -6
  9. data/lib/testcentricity_web/version.rb +1 -1
  10. data/lib/testcentricity_web/web_core/page_object.rb +53 -49
  11. data/lib/testcentricity_web/web_core/page_objects_helper.rb +20 -11
  12. data/lib/testcentricity_web/web_core/page_section.rb +31 -34
  13. data/lib/testcentricity_web/web_core/webdriver_helper.rb +379 -252
  14. data/lib/testcentricity_web/web_elements/audio.rb +6 -4
  15. data/lib/testcentricity_web/web_elements/button.rb +7 -4
  16. data/lib/testcentricity_web/web_elements/checkbox.rb +149 -147
  17. data/lib/testcentricity_web/web_elements/file_field.rb +38 -36
  18. data/lib/testcentricity_web/web_elements/image.rb +75 -70
  19. data/lib/testcentricity_web/web_elements/label.rb +6 -4
  20. data/lib/testcentricity_web/web_elements/link.rb +15 -13
  21. data/lib/testcentricity_web/web_elements/list.rb +171 -169
  22. data/lib/testcentricity_web/web_elements/media.rb +384 -379
  23. data/lib/testcentricity_web/web_elements/radio.rb +135 -133
  24. data/lib/testcentricity_web/web_elements/range.rb +16 -29
  25. data/lib/testcentricity_web/web_elements/select_list.rb +247 -245
  26. data/lib/testcentricity_web/web_elements/table.rb +575 -573
  27. data/lib/testcentricity_web/web_elements/textfield.rb +143 -139
  28. data/lib/testcentricity_web/web_elements/ui_element.rb +1171 -0
  29. data/lib/testcentricity_web/web_elements/video.rb +39 -37
  30. data/lib/testcentricity_web/world_extensions.rb +37 -4
  31. data/lib/testcentricity_web.rb +4 -23
  32. metadata +28 -80
  33. data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +0 -1148
@@ -1,161 +1,165 @@
1
1
  module TestCentricity
2
- class TextField < UIElement
3
- def initialize(name, parent, locator, context)
4
- super
5
- @type = :textfield
6
- end
2
+ module Elements
3
+ class TextField < UIElement
4
+ def initialize(name, parent, locator, context)
5
+ super
6
+ @type = :textfield
7
+ end
7
8
 
8
- # Is text field set to read-only?
9
- #
10
- # @return [Boolean]
11
- # @example
12
- # comments_field.read_only?
13
- #
14
- def read_only?
15
- obj, = find_element
16
- object_not_found_exception(obj, nil)
17
- !!obj.native.attribute('readonly')
18
- end
9
+ # Is text field set to read-only?
10
+ #
11
+ # @return [Boolean]
12
+ # @example
13
+ # comments_field.read_only?
14
+ #
15
+ def read_only?
16
+ obj, = find_element
17
+ object_not_found_exception(obj, nil)
18
+ !!obj.native.attribute('readonly')
19
+ end
19
20
 
20
- # Return maxlength character count of a text field.
21
- #
22
- # @return [Integer]
23
- # @example
24
- # max_num_chars = comments_field.get_max_length
25
- #
26
- def get_max_length
27
- obj, = find_element
28
- object_not_found_exception(obj, nil)
29
- max_length = obj.native.attribute('maxlength')
30
- max_length.to_i unless max_length.blank?
31
- end
21
+ # Return maxlength character count of a text field.
22
+ #
23
+ # @return [Integer]
24
+ # @example
25
+ # max_num_chars = comments_field.get_max_length
26
+ #
27
+ def get_max_length
28
+ obj, = find_element
29
+ object_not_found_exception(obj, nil)
30
+ max_length = obj.native.attribute('maxlength')
31
+ max_length.to_i unless max_length.blank?
32
+ end
32
33
 
33
- # Return placeholder text of a text field.
34
- #
35
- # @return [String]
36
- # @example
37
- # placeholder_message = username_field.get_placeholder
38
- #
39
- def get_placeholder
40
- obj, = find_element
41
- object_not_found_exception(obj, nil)
42
- obj.native.attribute('placeholder')
43
- end
34
+ # Return placeholder text of a text field.
35
+ #
36
+ # @return [String]
37
+ # @example
38
+ # placeholder_message = username_field.get_placeholder
39
+ #
40
+ def get_placeholder
41
+ obj, = find_element
42
+ object_not_found_exception(obj, nil)
43
+ obj.native.attribute('placeholder')
44
+ end
44
45
 
45
- # Return validationMessage property of a textfield, which is the message the browser displays to the user when a textfield's
46
- # validity is checked and fails. Note that each web browser provides a default localized message for this property, and message
47
- # strings can vary between different browsers (Chrome/Edge vs Firefox vs Safari).
48
- #
49
- # @return [String]
50
- # @example
51
- # message = username_field.validation_message
52
- #
53
- def validation_message
54
- obj, = find_element
55
- object_not_found_exception(obj, nil)
56
- obj.native.attribute('validationMessage')
57
- end
46
+ # Return validationMessage property of a textfield, which is the message the browser displays to the user when a textfield's
47
+ # validity is checked and fails. Note that each web browser provides a default localized message for this property, and message
48
+ # strings can vary between different browsers (Chrome/Edge vs Firefox vs Safari).
49
+ #
50
+ # @return [String]
51
+ # @example
52
+ # message = username_field.validation_message
53
+ #
54
+ def validation_message
55
+ obj, = find_element
56
+ object_not_found_exception(obj, nil)
57
+ obj.native.attribute('validationMessage')
58
+ end
58
59
 
59
- # Return Boolean value representing
60
- #
61
- # @param validity_state [Symbol] property to verify
62
- # @return [Boolean]
63
- # @example
64
- # username_field.validity?(:valid)
65
- # username_field.validity?(:valueMissing)
66
- #
67
- def validity?(validity_state)
68
- obj, = find_element
69
- object_not_found_exception(obj, nil)
70
- page.execute_script("return arguments[0].validity.#{validity_state}", obj)
71
- end
60
+ # Return Boolean value representing
61
+ #
62
+ # @param validity_state [Symbol] property to verify
63
+ # @return [Boolean]
64
+ # @example
65
+ # username_field.validity?(:valid)
66
+ # username_field.validity?(:valueMissing)
67
+ #
68
+ def validity?(validity_state)
69
+ obj, = find_element
70
+ object_not_found_exception(obj, nil)
71
+ page.execute_script("return arguments[0].validity.#{validity_state}", obj)
72
+ end
72
73
 
73
- # Return min attribute of a number type text field.
74
- #
75
- # @return [Integer]
76
- # @example
77
- # min_points_value = points_field.get_min
78
- #
79
- def get_min
80
- obj, = find_element
81
- object_not_found_exception(obj, nil)
82
- min = obj.native.attribute('min')
83
- unless min.blank?
84
- if min.is_int?
85
- min.to_i
86
- elsif min.is_float?
87
- min.to_f
88
- else
89
- min
74
+ # Return min attribute of a number type text field.
75
+ #
76
+ # @return [Integer]
77
+ # @example
78
+ # min_points_value = points_field.get_min
79
+ #
80
+ def get_min
81
+ obj, = find_element
82
+ object_not_found_exception(obj, nil)
83
+ min = obj.native.attribute('min')
84
+ unless min.blank?
85
+ if min.is_int?
86
+ min.to_i
87
+ elsif min.is_float?
88
+ min.to_f
89
+ else
90
+ min
91
+ end
90
92
  end
91
93
  end
92
- end
93
94
 
94
- # Return max attribute of a number type text field.
95
- #
96
- # @return [Integer]
97
- # @example
98
- # max_points_value = points_field.get_max
99
- #
100
- def get_max
101
- obj, = find_element
102
- object_not_found_exception(obj, nil)
103
- max = obj.native.attribute('max')
104
- unless max.blank?
105
- if max.is_int?
106
- max.to_i
107
- elsif max.is_float?
108
- max.to_f
109
- else
110
- max
95
+ # Return max attribute of a number type text field.
96
+ #
97
+ # @return [Integer]
98
+ # @example
99
+ # max_points_value = points_field.get_max
100
+ #
101
+ def get_max
102
+ obj, = find_element
103
+ object_not_found_exception(obj, nil)
104
+ max = obj.native.attribute('max')
105
+ unless max.blank?
106
+ if max.is_int?
107
+ max.to_i
108
+ elsif max.is_float?
109
+ max.to_f
110
+ else
111
+ max
112
+ end
111
113
  end
112
114
  end
113
- end
114
115
 
115
- # Return step attribute of a number type text field.
116
- #
117
- # @return [Integer]
118
- # @example
119
- # points_step = points_field.get_step
120
- #
121
- def get_step
122
- obj, = find_element
123
- object_not_found_exception(obj, nil)
124
- step = obj.native.attribute('step')
125
- unless step.blank?
126
- if step.is_int?
127
- step.to_i
128
- elsif step.is_float?
129
- step.to_f
130
- else
131
- step
116
+ # Return step attribute of a number type text field.
117
+ #
118
+ # @return [Integer]
119
+ # @example
120
+ # points_step = points_field.get_step
121
+ #
122
+ def get_step
123
+ obj, = find_element
124
+ object_not_found_exception(obj, nil)
125
+ step = obj.native.attribute('step')
126
+ unless step.blank?
127
+ if step.is_int?
128
+ step.to_i
129
+ elsif step.is_float?
130
+ step.to_f
131
+ else
132
+ step
133
+ end
132
134
  end
133
135
  end
134
- end
135
136
 
136
- # Clear the contents of a text field
137
- #
138
- # @example
139
- # first_name_field.clear
140
- #
141
- def clear
142
- case get_native_attribute('tagName').downcase.to_sym
143
- when :textarea
144
- set('')
145
- sleep(0.5)
146
- send_keys(:tab)
147
- when :div
148
- set('')
149
- else
150
- length = get_value.length
151
- length.times do
152
- send_keys(:backspace)
153
- end
154
- sleep(0.5)
155
- if get_value.length > 0
137
+ # Clear the contents of a text field
138
+ #
139
+ # @example
140
+ # first_name_field.clear
141
+ #
142
+ def clear
143
+ field_type = get_native_attribute('tagName')
144
+ field_type = field_type.downcase.to_sym unless field_type.nil?
145
+ case field_type
146
+ when :textarea
156
147
  set('')
157
148
  sleep(0.5)
158
149
  send_keys(:tab)
150
+ when :div, nil
151
+ set('')
152
+ else
153
+ length = get_value.length
154
+ length.times do
155
+ send_keys(:backspace)
156
+ end
157
+ sleep(0.5)
158
+ if get_value.length > 0
159
+ set('')
160
+ sleep(0.5)
161
+ send_keys(:tab)
162
+ end
159
163
  end
160
164
  end
161
165
  end