What is the difference if we invoke the findElement method using WebElement or WebDriver? Do each of them has advantage over the other? Thanks in advance.
The difference of findElement
between WebElement
and WebDriver
is the context.
Whereas the context of WebDriver
is the current page, the context of WebElement
is that element. WebDriver
will search across the whole document, while WebElement
will try to find the first child element from that node.
Note that when searching with WebElement
via XPath, starting with //
will still search across the entire document, not just the children of the current node. You can use .//
to limit the search results to the children of that WebElement
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments