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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -12
- data/LICENSE.md +1 -1
- data/README.md +1794 -697
- data/lib/devices/devices.yml +144 -216
- data/lib/testcentricity_web/browser_helper.rb +33 -4
- data/lib/testcentricity_web/data_objects/environment.rb +96 -13
- data/lib/testcentricity_web/exception_queue_helper.rb +5 -6
- data/lib/testcentricity_web/version.rb +1 -1
- data/lib/testcentricity_web/web_core/page_object.rb +53 -49
- data/lib/testcentricity_web/web_core/page_objects_helper.rb +20 -11
- data/lib/testcentricity_web/web_core/page_section.rb +31 -34
- data/lib/testcentricity_web/web_core/webdriver_helper.rb +379 -252
- data/lib/testcentricity_web/web_elements/audio.rb +6 -4
- data/lib/testcentricity_web/web_elements/button.rb +7 -4
- data/lib/testcentricity_web/web_elements/checkbox.rb +149 -147
- data/lib/testcentricity_web/web_elements/file_field.rb +38 -36
- data/lib/testcentricity_web/web_elements/image.rb +75 -70
- data/lib/testcentricity_web/web_elements/label.rb +6 -4
- data/lib/testcentricity_web/web_elements/link.rb +15 -13
- data/lib/testcentricity_web/web_elements/list.rb +171 -169
- data/lib/testcentricity_web/web_elements/media.rb +384 -379
- data/lib/testcentricity_web/web_elements/radio.rb +135 -133
- data/lib/testcentricity_web/web_elements/range.rb +16 -29
- data/lib/testcentricity_web/web_elements/select_list.rb +247 -245
- data/lib/testcentricity_web/web_elements/table.rb +575 -573
- data/lib/testcentricity_web/web_elements/textfield.rb +143 -139
- data/lib/testcentricity_web/web_elements/ui_element.rb +1171 -0
- data/lib/testcentricity_web/web_elements/video.rb +39 -37
- data/lib/testcentricity_web/world_extensions.rb +37 -4
- data/lib/testcentricity_web.rb +4 -23
- metadata +28 -80
- data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +0 -1148
@@ -1,161 +1,165 @@
|
|
1
1
|
module TestCentricity
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
module Elements
|
3
|
+
class TextField < UIElement
|
4
|
+
def initialize(name, parent, locator, context)
|
5
|
+
super
|
6
|
+
@type = :textfield
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
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
|