2424def test_should_return_null_when_getting_the_value_of_an_attribute_that_is_not_listed (driver , pages ):
2525 pages .load ("simpleTest.html" )
2626 head = driver .find_element (By .XPATH , "/html" )
27- attribute = head .get_attribute ("cheese" )
27+ attribute = head .get_dom_attribute ("cheese" )
2828 assert attribute is None
2929
3030
3131def test_should_return_null_when_getting_src_attribute_of_invalid_img_tag (driver , pages ):
3232 pages .load ("simpleTest.html" )
3333 img = driver .find_element (By .ID , "invalidImgTag" )
34- img_attr = img .get_attribute ("src" )
34+ img_attr = img .get_dom_attribute ("src" )
3535 assert img_attr is None
3636
3737
3838def test_should_return_an_absolute_url_when_getting_src_attribute_of_avalid_img_tag (driver , pages ):
3939 pages .load ("simpleTest.html" )
4040 img = driver .find_element (By .ID , "validImgTag" )
41- img_attr = img .get_attribute ("src" )
41+ img_attr = img .get_dom_attribute ("src" )
4242 assert "icon.gif" in img_attr
4343
4444
4545def test_should_return_an_absolute_url_when_getting_href_attribute_of_avalid_anchor_tag (driver , pages ):
4646 pages .load ("simpleTest.html" )
4747 img = driver .find_element (By .ID , "validAnchorTag" )
48- img_attr = img .get_attribute ("href" )
48+ img_attr = img .get_dom_attribute ("href" )
4949 assert "icon.gif" in img_attr
5050
5151
5252def test_should_return_empty_attribute_values_when_present_and_the_value_is_actually_empty (driver , pages ):
5353 pages .load ("simpleTest.html" )
5454 body = driver .find_element (By .XPATH , "//body" )
55- assert "" == body .get_attribute ("style" )
55+ assert "" == body .get_dom_attribute ("style" )
5656
5757
5858def test_should_return_the_value_of_the_disabled_attribute_as_false_if_not_set (driver , pages ):
5959 pages .load ("formPage.html" )
6060 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
6262 assert inputElement .is_enabled ()
6363
6464 pElement = driver .find_element (By .ID , "peas" )
65- assert pElement .get_attribute ("disabled" ) is None
65+ assert pElement .get_dom_attribute ("disabled" ) is None
6666 assert pElement .is_enabled ()
6767
6868
6969def test_should_return_the_value_of_the_index_attribute_even_if_it_is_missing (driver , pages ):
7070 pages .load ("formPage.html" )
7171 multiSelect = driver .find_element (By .ID , "multi" )
7272 options = multiSelect .find_elements (By .TAG_NAME , "option" )
73- assert "1" == options [1 ].get_attribute ("index" )
73+ assert 1 == options [1 ].get_property ("index" )
7474
7575
7676def 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):
126126def test_should_return_the_value_of_checked_for_acheckbox_even_if_it_lacks_that_attribute (driver , pages ):
127127 pages .load ("formPage.html" )
128128 checkbox = driver .find_element (By .XPATH , "//input[@id='checky']" )
129- assert checkbox .get_attribute ("checked" ) is None
129+ assert checkbox .get_property ("checked" ) == False
130130 checkbox .click ()
131- assert "true" == checkbox .get_attribute ("checked" )
131+ assert True == checkbox .get_property ("checked" )
132132
133133
134134def 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
137137 initiallyNotSelected = driver .find_element (By .ID , "peas" )
138138 initiallySelected = driver .find_element (By .ID , "cheese_and_peas" )
139139
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" ) == False
141+ assert initiallyNotSelected .get_property ("checked" ) == False
142+ assert True == initiallySelected .get_property ("checked" )
143143
144144 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 == initiallyNotSelected .get_property ("checked" )
147+ assert initiallySelected .get_property ("checked" ) == False
148148
149149
150150def test_should_return_the_value_of_selected_for_options_in_selects_even_if_they_lack_that_attribute (driver , pages ):
@@ -155,14 +155,15 @@ def test_should_return_the_value_of_selected_for_options_in_selects_even_if_they
155155 two = options [1 ]
156156 assert one .is_selected ()
157157 assert not two .is_selected ()
158- assert "true" == one .get_attribute ("selected" )
159- assert two .get_attribute ("selected" ) is None
158+ assert "true" == one .get_dom_attribute ("selected" )
159+ assert True == one .get_property ("selected" )
160+ assert two .get_dom_attribute ("selected" ) is None
160161
161162
162163def test_should_return_value_of_class_attribute_of_an_element (driver , pages ):
163164 pages .load ("xhtmlTest.html" )
164165 heading = driver .find_element (By .XPATH , "//h1" )
165- classname = heading .get_attribute ("class" )
166+ classname = heading .get_dom_attribute ("class" )
166167 assert "header" == classname
167168
168169
@@ -172,44 +173,44 @@ def test_should_return_value_of_class_attribute_of_an_element(driver, pages):
172173# driver.switch_to.frame("iframe1")
173174#
174175# wallace = driver.find_element(By.XPATH, "//div[@id='wallace']")
175- # classname = wallace.get_attribute ("class")
176+ # classname = wallace.get_dom_attribute ("class")
176177# assert "gromit" == classname
177178
178179
179180def test_should_return_the_contents_of_atext_area_as_its_value (driver , pages ):
180181 pages .load ("formPage.html" )
181- value = driver .find_element (By .ID , "withText" ).get_attribute ("value" )
182+ value = driver .find_element (By .ID , "withText" ).get_property ("value" )
182183 assert "Example text" == value
183184
184185
185186def test_should_return_the_contents_of_atext_area_as_its_value_when_set_to_non_norminal_true (driver , pages ):
186187 pages .load ("formPage.html" )
187188 e = driver .find_element (By .ID , "withText" )
188189 driver .execute_script ("arguments[0].value = 'tRuE'" , e )
189- value = e .get_attribute ("value" )
190+ value = e .get_property ("value" )
190191 assert "tRuE" == value
191192
192193
193194def test_should_treat_readonly_as_avalue (driver , pages ):
194195 pages .load ("formPage.html" )
195196 element = driver .find_element (By .NAME , "readonly" )
196- readOnlyAttribute = element .get_attribute ("readonly" )
197+ readOnlyAttribute = element .get_dom_attribute ("readonly" )
197198
198199 textInput = driver .find_element (By .NAME , "x" )
199- notReadOnly = textInput .get_attribute ("readonly" )
200+ notReadOnly = textInput .get_dom_attribute ("readonly" )
200201
201202 assert readOnlyAttribute != notReadOnly
202203
203204
204205def test_should_get_numeric_attribute (driver , pages ):
205206 pages .load ("formPage.html" )
206207 element = driver .find_element (By .ID , "withText" )
207- assert "5" == element .get_attribute ("rows" )
208+ assert "5" == element .get_dom_attribute ("rows" )
208209
209210
210211def test_can_return_atext_approximation_of_the_style_attribute (driver , pages ):
211212 pages .load ("javascriptPage.html" )
212- style = driver .find_element (By .ID , "red-item" ).get_attribute ("style" )
213+ style = driver .find_element (By .ID , "red-item" ).get_dom_attribute ("style" )
213214 assert "background-color" in style .lower ()
214215
215216
@@ -219,54 +220,54 @@ def test_should_correctly_report_value_of_colspan(driver, pages):
219220 th1 = driver .find_element (By .ID , "th1" )
220221 td2 = driver .find_element (By .ID , "td2" )
221222
222- assert "th1" == th1 .get_attribute ("id" )
223- assert "3" == th1 .get_attribute ("colspan" )
223+ assert "th1" == th1 .get_dom_attribute ("id" )
224+ assert "3" == th1 .get_dom_attribute ("colspan" )
224225
225- assert "td2" == td2 .get_attribute ("id" )
226- assert "2" == td2 .get_attribute ("colspan" )
226+ assert "td2" == td2 .get_dom_attribute ("id" )
227+ assert "2" == td2 .get_dom_attribute ("colspan" )
227228
228229
229230def test_can_retrieve_the_current_value_of_atext_form_field_text_input (driver , pages ):
230231 pages .load ("formPage.html" )
231232 element = driver .find_element (By .ID , "working" )
232- assert "" == element .get_attribute ("value" )
233+ assert "" == element .get_property ("value" )
233234 element .send_keys ("hello world" )
234- assert "hello world" == element .get_attribute ("value" )
235+ assert "hello world" == element .get_property ("value" )
235236
236237
237238def test_can_retrieve_the_current_value_of_atext_form_field_email_input (driver , pages ):
238239 pages .load ("formPage.html" )
239240 element = driver .find_element (By .ID , "email" )
240- assert "" == element .get_attribute ("value" )
241+ assert "" == element .get_property ("value" )
241242 element .
send_keys (
"[email protected] " )
242- assert "[email protected] " == element .
get_attribute (
"value" )
243+ assert "[email protected] " == element .
get_property (
"value" )
243244
244245
245246def test_can_retrieve_the_current_value_of_atext_form_field_text_area (driver , pages ):
246247 pages .load ("formPage.html" )
247248 element = driver .find_element (By .ID , "emptyTextArea" )
248- assert "" == element .get_attribute ("value" )
249+ assert "" == element .get_property ("value" )
249250 element .send_keys ("hello world" )
250- assert "hello world" == element .get_attribute ("value" )
251+ assert "hello world" == element .get_property ("value" )
251252
252253
253254def test_should_return_null_for_non_present_boolean_attributes (driver , pages ):
254255 pages .load ("booleanAttributes.html" )
255256 element1 = driver .find_element (By .ID , "working" )
256- assert element1 .get_attribute ("required" ) is None
257+ assert element1 .get_dom_attribute ("required" ) is None
257258
258259
259260@pytest .mark .xfail_ie
260261def test_should_return_true_for_present_boolean_attributes (driver , pages ):
261262 pages .load ("booleanAttributes.html" )
262263 element1 = driver .find_element (By .ID , "emailRequired" )
263- assert "true" == element1 .get_attribute ("required" )
264+ assert "true" == element1 .get_dom_attribute ("required" )
264265 element2 = driver .find_element (By .ID , "emptyTextAreaRequired" )
265- assert "true" == element2 .get_attribute ("required" )
266+ assert "true" == element2 .get_dom_attribute ("required" )
266267 element3 = driver .find_element (By .ID , "inputRequired" )
267- assert "true" == element3 .get_attribute ("required" )
268+ assert "true" == element3 .get_dom_attribute ("required" )
268269 element4 = driver .find_element (By .ID , "textAreaRequired" )
269- assert "true" == element4 .get_attribute ("required" )
270+ assert "true" == element4 .get_dom_attribute ("required" )
270271
271272
272273@pytest .mark .xfail_chrome
@@ -276,7 +277,7 @@ def test_should_return_true_for_present_boolean_attributes(driver, pages):
276277@pytest .mark .xfail_remote
277278def test_should_get_unicode_chars_from_attribute (driver , pages ):
278279 pages .load ("formPage.html" )
279- title = driver .find_element (By .ID , "vsearchGadget" ).get_attribute ("title" )
280+ title = driver .find_element (By .ID , "vsearchGadget" ).get_dom_attribute ("title" )
280281 assert "Hvad s\xf8 ger du?" == title
281282
282283
@@ -288,5 +289,5 @@ def test_should_get_unicode_chars_from_attribute(driver, pages):
288289def test_should_get_values_and_not_miss_items (driver , pages ):
289290 pages .load ("attributes.html" )
290291 expected = "4b273a33fbbd29013nN93dy4F1A~"
291- result = driver .find_element (By .CSS_SELECTOR , "li" ).get_attribute ("value" )
292+ result = driver .find_element (By .CSS_SELECTOR , "li" ).get_property ("value" )
292293 assert expected == result
0 commit comments