24
24
def test_should_return_null_when_getting_the_value_of_an_attribute_that_is_not_listed (driver , pages ):
25
25
pages .load ("simpleTest.html" )
26
26
head = driver .find_element (By .XPATH , "/html" )
27
- attribute = head .get_attribute ("cheese" )
27
+ attribute = head .get_dom_attribute ("cheese" )
28
28
assert attribute is None
29
29
30
30
31
31
def test_should_return_null_when_getting_src_attribute_of_invalid_img_tag (driver , pages ):
32
32
pages .load ("simpleTest.html" )
33
33
img = driver .find_element (By .ID , "invalidImgTag" )
34
- img_attr = img .get_attribute ("src" )
34
+ img_attr = img .get_dom_attribute ("src" )
35
35
assert img_attr is None
36
36
37
37
38
38
def test_should_return_an_absolute_url_when_getting_src_attribute_of_avalid_img_tag (driver , pages ):
39
39
pages .load ("simpleTest.html" )
40
40
img = driver .find_element (By .ID , "validImgTag" )
41
- img_attr = img .get_attribute ("src" )
41
+ img_attr = img .get_dom_attribute ("src" )
42
42
assert "icon.gif" in img_attr
43
43
44
44
45
45
def test_should_return_an_absolute_url_when_getting_href_attribute_of_avalid_anchor_tag (driver , pages ):
46
46
pages .load ("simpleTest.html" )
47
47
img = driver .find_element (By .ID , "validAnchorTag" )
48
- img_attr = img .get_attribute ("href" )
48
+ img_attr = img .get_dom_attribute ("href" )
49
49
assert "icon.gif" in img_attr
50
50
51
51
52
52
def test_should_return_empty_attribute_values_when_present_and_the_value_is_actually_empty (driver , pages ):
53
53
pages .load ("simpleTest.html" )
54
54
body = driver .find_element (By .XPATH , "//body" )
55
- assert "" == body .get_attribute ("style" )
55
+ assert "" == body .get_dom_attribute ("style" )
56
56
57
57
58
58
def test_should_return_the_value_of_the_disabled_attribute_as_false_if_not_set (driver , pages ):
59
59
pages .load ("formPage.html" )
60
60
inputElement = driver .find_element (By .XPATH , "//input[@id='working']" )
61
- assert inputElement .get_attribute ("disabled" ) is None
61
+ assert inputElement .get_dom_attribute ("disabled" ) is None
62
62
assert inputElement .is_enabled ()
63
63
64
64
pElement = driver .find_element (By .ID , "peas" )
65
- assert pElement .get_attribute ("disabled" ) is None
65
+ assert pElement .get_dom_attribute ("disabled" ) is None
66
66
assert pElement .is_enabled ()
67
67
68
68
69
69
def test_should_return_the_value_of_the_index_attribute_even_if_it_is_missing (driver , pages ):
70
70
pages .load ("formPage.html" )
71
71
multiSelect = driver .find_element (By .ID , "multi" )
72
72
options = multiSelect .find_elements (By .TAG_NAME , "option" )
73
- assert "1" == options [1 ].get_attribute ("index" )
73
+ assert 1 == options [1 ].get_property ("index" )
74
74
75
75
76
76
def test_should_indicate_the_elements_that_are_disabled_are_not_is_enabled (driver , pages ):
@@ -126,9 +126,9 @@ def test_should_indicate_when_aselect_is_disabled(driver, pages):
126
126
def test_should_return_the_value_of_checked_for_acheckbox_even_if_it_lacks_that_attribute (driver , pages ):
127
127
pages .load ("formPage.html" )
128
128
checkbox = driver .find_element (By .XPATH , "//input[@id='checky']" )
129
- assert checkbox .get_attribute ("checked" ) is None
129
+ assert checkbox .get_property ("checked" ) is False
130
130
checkbox .click ()
131
- assert "true" == checkbox .get_attribute ("checked" )
131
+ assert True is checkbox .get_property ("checked" )
132
132
133
133
134
134
def test_should_return_the_value_of_selected_for_radio_buttons_even_if_they_lack_that_attribute (driver , pages ):
@@ -137,14 +137,14 @@ def test_should_return_the_value_of_selected_for_radio_buttons_even_if_they_lack
137
137
initiallyNotSelected = driver .find_element (By .ID , "peas" )
138
138
initiallySelected = driver .find_element (By .ID , "cheese_and_peas" )
139
139
140
- assert neverSelected .get_attribute ("checked" ) is None
141
- assert initiallyNotSelected .get_attribute ("checked" ) is None
142
- assert "true" == initiallySelected .get_attribute ("checked" )
140
+ assert neverSelected .get_property ("checked" ) is False
141
+ assert initiallyNotSelected .get_property ("checked" ) is False
142
+ assert True is initiallySelected .get_property ("checked" )
143
143
144
144
initiallyNotSelected .click ()
145
- assert neverSelected .get_attribute ("selected" ) is None
146
- assert "true" == initiallyNotSelected .get_attribute ("checked" )
147
- assert initiallySelected .get_attribute ("checked" ) is None
145
+ assert neverSelected .get_property ("selected" ) is None
146
+ assert True is initiallyNotSelected .get_property ("checked" )
147
+ assert initiallySelected .get_property ("checked" ) is False
148
148
149
149
150
150
def test_should_return_the_value_of_selected_for_options_in_selects_even_if_they_lack_that_attribute (driver , pages ):
@@ -155,14 +155,14 @@ def test_should_return_the_value_of_selected_for_options_in_selects_even_if_they
155
155
two = options [1 ]
156
156
assert one .is_selected ()
157
157
assert not two .is_selected ()
158
- assert "true" == one .get_attribute ("selected" )
159
- assert two .get_attribute ("selected" ) is None
158
+ assert True is one .get_property ("selected" )
159
+ assert two .get_property ("selected" ) is False
160
160
161
161
162
162
def test_should_return_value_of_class_attribute_of_an_element (driver , pages ):
163
163
pages .load ("xhtmlTest.html" )
164
164
heading = driver .find_element (By .XPATH , "//h1" )
165
- classname = heading .get_attribute ("class" )
165
+ classname = heading .get_dom_attribute ("class" )
166
166
assert "header" == classname
167
167
168
168
@@ -172,44 +172,44 @@ def test_should_return_value_of_class_attribute_of_an_element(driver, pages):
172
172
# driver.switch_to.frame("iframe1")
173
173
#
174
174
# wallace = driver.find_element(By.XPATH, "//div[@id='wallace']")
175
- # classname = wallace.get_attribute ("class")
175
+ # classname = wallace.get_dom_attribute ("class")
176
176
# assert "gromit" == classname
177
177
178
178
179
179
def test_should_return_the_contents_of_atext_area_as_its_value (driver , pages ):
180
180
pages .load ("formPage.html" )
181
- value = driver .find_element (By .ID , "withText" ).get_attribute ("value" )
181
+ value = driver .find_element (By .ID , "withText" ).get_property ("value" )
182
182
assert "Example text" == value
183
183
184
184
185
185
def test_should_return_the_contents_of_atext_area_as_its_value_when_set_to_non_norminal_true (driver , pages ):
186
186
pages .load ("formPage.html" )
187
187
e = driver .find_element (By .ID , "withText" )
188
188
driver .execute_script ("arguments[0].value = 'tRuE'" , e )
189
- value = e .get_attribute ("value" )
189
+ value = e .get_property ("value" )
190
190
assert "tRuE" == value
191
191
192
192
193
193
def test_should_treat_readonly_as_avalue (driver , pages ):
194
194
pages .load ("formPage.html" )
195
195
element = driver .find_element (By .NAME , "readonly" )
196
- readOnlyAttribute = element .get_attribute ("readonly" )
196
+ readOnlyAttribute = element .get_dom_attribute ("readonly" )
197
197
198
198
textInput = driver .find_element (By .NAME , "x" )
199
- notReadOnly = textInput .get_attribute ("readonly" )
199
+ notReadOnly = textInput .get_dom_attribute ("readonly" )
200
200
201
201
assert readOnlyAttribute != notReadOnly
202
202
203
203
204
204
def test_should_get_numeric_attribute (driver , pages ):
205
205
pages .load ("formPage.html" )
206
206
element = driver .find_element (By .ID , "withText" )
207
- assert "5" == element .get_attribute ("rows" )
207
+ assert "5" == element .get_dom_attribute ("rows" )
208
208
209
209
210
210
def test_can_return_atext_approximation_of_the_style_attribute (driver , pages ):
211
211
pages .load ("javascriptPage.html" )
212
- style = driver .find_element (By .ID , "red-item" ).get_attribute ("style" )
212
+ style = driver .find_element (By .ID , "red-item" ).get_dom_attribute ("style" )
213
213
assert "background-color" in style .lower ()
214
214
215
215
@@ -219,54 +219,54 @@ def test_should_correctly_report_value_of_colspan(driver, pages):
219
219
th1 = driver .find_element (By .ID , "th1" )
220
220
td2 = driver .find_element (By .ID , "td2" )
221
221
222
- assert "th1" == th1 .get_attribute ("id" )
223
- assert "3" == th1 .get_attribute ("colspan" )
222
+ assert "th1" == th1 .get_dom_attribute ("id" )
223
+ assert "3" == th1 .get_dom_attribute ("colspan" )
224
224
225
- assert "td2" == td2 .get_attribute ("id" )
226
- assert "2" == td2 .get_attribute ("colspan" )
225
+ assert "td2" == td2 .get_dom_attribute ("id" )
226
+ assert "2" == td2 .get_dom_attribute ("colspan" )
227
227
228
228
229
229
def test_can_retrieve_the_current_value_of_atext_form_field_text_input (driver , pages ):
230
230
pages .load ("formPage.html" )
231
231
element = driver .find_element (By .ID , "working" )
232
- assert "" == element .get_attribute ("value" )
232
+ assert "" == element .get_property ("value" )
233
233
element .send_keys ("hello world" )
234
- assert "hello world" == element .get_attribute ("value" )
234
+ assert "hello world" == element .get_property ("value" )
235
235
236
236
237
237
def test_can_retrieve_the_current_value_of_atext_form_field_email_input (driver , pages ):
238
238
pages .load ("formPage.html" )
239
239
element = driver .find_element (By .ID , "email" )
240
- assert "" == element .get_attribute ("value" )
240
+ assert "" == element .get_property ("value" )
241
241
element .
send_keys (
"[email protected] " )
242
- assert "[email protected] " == element .
get_attribute (
"value" )
242
+ assert "[email protected] " == element .
get_property (
"value" )
243
243
244
244
245
245
def test_can_retrieve_the_current_value_of_atext_form_field_text_area (driver , pages ):
246
246
pages .load ("formPage.html" )
247
247
element = driver .find_element (By .ID , "emptyTextArea" )
248
- assert "" == element .get_attribute ("value" )
248
+ assert "" == element .get_property ("value" )
249
249
element .send_keys ("hello world" )
250
- assert "hello world" == element .get_attribute ("value" )
250
+ assert "hello world" == element .get_property ("value" )
251
251
252
252
253
253
def test_should_return_null_for_non_present_boolean_attributes (driver , pages ):
254
254
pages .load ("booleanAttributes.html" )
255
255
element1 = driver .find_element (By .ID , "working" )
256
- assert element1 .get_attribute ("required" ) is None
256
+ assert element1 .get_dom_attribute ("required" ) is None
257
257
258
258
259
259
@pytest .mark .xfail_ie
260
260
def test_should_return_true_for_present_boolean_attributes (driver , pages ):
261
261
pages .load ("booleanAttributes.html" )
262
262
element1 = driver .find_element (By .ID , "emailRequired" )
263
- assert "true" == element1 .get_attribute ("required" )
263
+ assert "true" == element1 .get_dom_attribute ("required" )
264
264
element2 = driver .find_element (By .ID , "emptyTextAreaRequired" )
265
- assert "true" == element2 .get_attribute ("required" )
265
+ assert "true" == element2 .get_dom_attribute ("required" )
266
266
element3 = driver .find_element (By .ID , "inputRequired" )
267
- assert "true" == element3 .get_attribute ("required" )
267
+ assert "true" == element3 .get_dom_attribute ("required" )
268
268
element4 = driver .find_element (By .ID , "textAreaRequired" )
269
- assert "true" == element4 .get_attribute ("required" )
269
+ assert "true" == element4 .get_dom_attribute ("required" )
270
270
271
271
272
272
@pytest .mark .xfail_chrome
@@ -276,7 +276,7 @@ def test_should_return_true_for_present_boolean_attributes(driver, pages):
276
276
@pytest .mark .xfail_remote
277
277
def test_should_get_unicode_chars_from_attribute (driver , pages ):
278
278
pages .load ("formPage.html" )
279
- title = driver .find_element (By .ID , "vsearchGadget" ).get_attribute ("title" )
279
+ title = driver .find_element (By .ID , "vsearchGadget" ).get_dom_attribute ("title" )
280
280
assert "Hvad s\xf8 ger du?" == title
281
281
282
282
@@ -288,5 +288,5 @@ def test_should_get_unicode_chars_from_attribute(driver, pages):
288
288
def test_should_get_values_and_not_miss_items (driver , pages ):
289
289
pages .load ("attributes.html" )
290
290
expected = "4b273a33fbbd29013nN93dy4F1A~"
291
- result = driver .find_element (By .CSS_SELECTOR , "li" ).get_attribute ("value" )
291
+ result = driver .find_element (By .CSS_SELECTOR , "li" ).get_property ("value" )
292
292
assert expected == result
0 commit comments