Does WebElement class inherits from WebDriver class in Selenium Python?

47 views Asked by At

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?

1

There are 1 answers

1
undetected Selenium On

As per the Selenium Python binding documentation:


Conclusion

Hence driver.find_element(By.ID, 'foo') and element.find_element(By.ID, 'foo') both are valid lies of code.