WebElement and WebDriver | Selenium Forum
20% Off Learning Discount Avail now

WebElement and WebDriver

Pinki Daga Post on 01/10/2019

WebDriver driver = new ChromeDriver();

WebElement u = driver.findElement(By.id("user"));


1. in first line, I am creating driver objct of class ChromeDriver which implements WebDriver inteface, is this understanding correct?

2. 2nd line -

findElement is a method on interface WebDriver. This method returns an object of interface 'WebElement', is this correct?

findElement method is present under both WebDriver and WebElement class, why?



Support Team Reply on 09/10/2019

1. Yes, it is correct.

2. This is because we may need to find some elements located under the element we already located.

Pinki Daga Reply on 21/10/2019

thanks, we can close this