Sample code:
score_both_halves = driver.find_element_by_xpath('//label[@data-btn-radio="\'ScoreBothHalves\'"]')
score_both_halves.find_element_by_xpath()
In the second line of code I used a find_element_by_xpath() method of Webdriver class with WebElement object and it works fine.
How is that possible? Is WebElement class inherits from WebDriver class in selenium python?
Isn't the WebElement class inherits from WebDriver class in selenium python? If not then how we can use methods of WebDriver class with WebElement object?
As per the Selenium Python binding documentation:
The Remote WebDriver implementation contains the method find_element()
Usage:
Return type:
Similarly The Remote WebElement implementation also includes the method find_element()
Usage:
Return type:
Conclusion
Hence
driver.find_element(By.ID, 'foo')andelement.find_element(By.ID, 'foo')both are valid lies of code.