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" ) is False
130130 checkbox .click ()
131- assert "true" == checkbox .get_attribute ("checked" )
131+ assert True is 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" ) is False
141+ assert initiallyNotSelected .get_property ("checked" ) is False
142+ assert True is 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 is initiallyNotSelected .get_property ("checked" )
147+ assert initiallySelected .get_property ("checked" ) is 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,14 @@ 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 is one .get_property ("selected" )
159+ assert two .get_property ("selected" ) is False
160160
161161
162162def test_should_return_value_of_class_attribute_of_an_element (driver , pages ):
163163 pages .load ("xhtmlTest.html" )
164164 heading = driver .find_element (By .XPATH , "//h1" )
165- classname = heading .get_attribute ("class" )
165+ classname = heading .get_dom_attribute ("class" )
166166 assert "header" == classname
167167
168168
@@ -172,44 +172,44 @@ def test_should_return_value_of_class_attribute_of_an_element(driver, pages):
172172# driver.switch_to.frame("iframe1")
173173#
174174# wallace = driver.find_element(By.XPATH, "//div[@id='wallace']")
175- # classname = wallace.get_attribute ("class")
175+ # classname = wallace.get_dom_attribute ("class")
176176# assert "gromit" == classname
177177
178178
179179def test_should_return_the_contents_of_atext_area_as_its_value (driver , pages ):
180180 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" )
182182 assert "Example text" == value
183183
184184
185185def test_should_return_the_contents_of_atext_area_as_its_value_when_set_to_non_norminal_true (driver , pages ):
186186 pages .load ("formPage.html" )
187187 e = driver .find_element (By .ID , "withText" )
188188 driver .execute_script ("arguments[0].value = 'tRuE'" , e )
189- value = e .get_attribute ("value" )
189+ value = e .get_property ("value" )
190190 assert "tRuE" == value
191191
192192
193193def test_should_treat_readonly_as_avalue (driver , pages ):
194194 pages .load ("formPage.html" )
195195 element = driver .find_element (By .NAME , "readonly" )
196- readOnlyAttribute = element .get_attribute ("readonly" )
196+ readOnlyAttribute = element .get_dom_attribute ("readonly" )
197197
198198 textInput = driver .find_element (By .NAME , "x" )
199- notReadOnly = textInput .get_attribute ("readonly" )
199+ notReadOnly = textInput .get_dom_attribute ("readonly" )
200200
201201 assert readOnlyAttribute != notReadOnly
202202
203203
204204def test_should_get_numeric_attribute (driver , pages ):
205205 pages .load ("formPage.html" )
206206 element = driver .find_element (By .ID , "withText" )
207- assert "5" == element .get_attribute ("rows" )
207+ assert "5" == element .get_dom_attribute ("rows" )
208208
209209
210210def test_can_return_atext_approximation_of_the_style_attribute (driver , pages ):
211211 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" )
213213 assert "background-color" in style .lower ()
214214
215215
@@ -219,54 +219,54 @@ def test_should_correctly_report_value_of_colspan(driver, pages):
219219 th1 = driver .find_element (By .ID , "th1" )
220220 td2 = driver .find_element (By .ID , "td2" )
221221
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" )
224224
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" )
227227
228228
229229def test_can_retrieve_the_current_value_of_atext_form_field_text_input (driver , pages ):
230230 pages .load ("formPage.html" )
231231 element = driver .find_element (By .ID , "working" )
232- assert "" == element .get_attribute ("value" )
232+ assert "" == element .get_property ("value" )
233233 element .send_keys ("hello world" )
234- assert "hello world" == element .get_attribute ("value" )
234+ assert "hello world" == element .get_property ("value" )
235235
236236
237237def test_can_retrieve_the_current_value_of_atext_form_field_email_input (driver , pages ):
238238 pages .load ("formPage.html" )
239239 element = driver .find_element (By .ID , "email" )
240- assert "" == element .get_attribute ("value" )
240+ assert "" == element .get_property ("value" )
241241 element .
send_keys (
"[email protected] " )
242- assert "[email protected] " == element .
get_attribute (
"value" )
242+ assert "[email protected] " == element .
get_property (
"value" )
243243
244244
245245def test_can_retrieve_the_current_value_of_atext_form_field_text_area (driver , pages ):
246246 pages .load ("formPage.html" )
247247 element = driver .find_element (By .ID , "emptyTextArea" )
248- assert "" == element .get_attribute ("value" )
248+ assert "" == element .get_property ("value" )
249249 element .send_keys ("hello world" )
250- assert "hello world" == element .get_attribute ("value" )
250+ assert "hello world" == element .get_property ("value" )
251251
252252
253253def test_should_return_null_for_non_present_boolean_attributes (driver , pages ):
254254 pages .load ("booleanAttributes.html" )
255255 element1 = driver .find_element (By .ID , "working" )
256- assert element1 .get_attribute ("required" ) is None
256+ assert element1 .get_dom_attribute ("required" ) is None
257257
258258
259259@pytest .mark .xfail_ie
260260def test_should_return_true_for_present_boolean_attributes (driver , pages ):
261261 pages .load ("booleanAttributes.html" )
262262 element1 = driver .find_element (By .ID , "emailRequired" )
263- assert "true" == element1 .get_attribute ("required" )
263+ assert "true" == element1 .get_dom_attribute ("required" )
264264 element2 = driver .find_element (By .ID , "emptyTextAreaRequired" )
265- assert "true" == element2 .get_attribute ("required" )
265+ assert "true" == element2 .get_dom_attribute ("required" )
266266 element3 = driver .find_element (By .ID , "inputRequired" )
267- assert "true" == element3 .get_attribute ("required" )
267+ assert "true" == element3 .get_dom_attribute ("required" )
268268 element4 = driver .find_element (By .ID , "textAreaRequired" )
269- assert "true" == element4 .get_attribute ("required" )
269+ assert "true" == element4 .get_dom_attribute ("required" )
270270
271271
272272@pytest .mark .xfail_chrome
@@ -276,7 +276,7 @@ def test_should_return_true_for_present_boolean_attributes(driver, pages):
276276@pytest .mark .xfail_remote
277277def test_should_get_unicode_chars_from_attribute (driver , pages ):
278278 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" )
280280 assert "Hvad s\xf8 ger du?" == title
281281
282282
@@ -288,5 +288,5 @@ def test_should_get_unicode_chars_from_attribute(driver, pages):
288288def test_should_get_values_and_not_miss_items (driver , pages ):
289289 pages .load ("attributes.html" )
290290 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" )
292292 assert expected == result
0 commit comments