Issue
Selenium WebElement has 2 methods, in Python, they are 'get_attribute' and 'get_property' . The documentation is very simple and unclear to me.
What is the difference of them on earth?
Solution
An attribute is a static attribute of a given DOM node, as where a property is a computed property of the DOM node object. An example of a property would be the checked
state of a checkbox, or value
or an input field. As where an attribute would be href
of an anchor tag or the type
of an input DOM.
<a href="https://google.com" id="hello">Hello World</a>
<input type="checkbox" id="foo" checked>
<input type="text" id="bar" value="cheesecake">
link_location = document.querySelector('#hello').getAttribute('href')
// # href="https://google.com"
input_checkbox = document.querySelector('#foo').getAttribute('type')
// # type="checkbox"
checkbox_checked = document.querySelector('#foo').checked
// # computed property of the DOM node
textbox_value = document.querySelector('#bar').value
// # computed property of the DOM node
https://www.w3schools.com/jsref/dom_obj_all.asp
Answered By - neet_jn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.