WebElement(s)
WebElement Interface
Last updated
Was this helpful?
WebElement Interface
Last updated
Was this helpful?
WebElement is an interface in selenium which will a representation of any object we see on a web page. For example button, input box, link, text, image, etc.,
Since it an interface and we'll not be able to instantiate it. But we can get the WebElement object from the driver that we already have.
By is one more important to class which provides or describes the mechanism from which we are identifying a particular element in a web page. It has all the locator mechanism that we discussed in .
Example:
Etc.,
Now the element is the object representation of the element in the web page.
Many a times we come across situations we want to interact with similar kind of elements in a single page which share same locators, or there will be multiple elements matched for the locator that we have written and we wanna filter it, in any case finding WebElements instead of finding a single web element will be handy. WebElements is no class.
Finding a list of web elements has lots of benefits than finding a single element in many situations, Some of them are 1. Finding all options of a select block. 2. Finding all elements of ordered or un-ordered list. Etc.,
Once we find the WebElement, we can call methods corresponding to the actions the we would perform on an element in a web page. Like click, enter text, copy text, drag, drop etc.,
And there are many ways we can leverage list of