WebElement and WebDriver | Selenium Forum
P
Pinki Daga Posted 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?


A
Ashish Thakur Replied 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.


P
Pinki Daga Replied on 21/10/2019

thanks, we can close this