WebElement类是否继承自Selenium Python中的WebDriver类?

huangapple go评论74阅读模式
英文:

Does WebElement class inherits from WebDriver class in Selenium Python?

问题

在代码的第二行,我使用了Webdriver类的find_element_by_xpath()方法与WebElement对象,它运行正常。

这是如何实现的呢?在Selenium Python中,WebElement类是否继承自WebDriver类?

Selenium Python中的WebElement类并没有继承自WebDriver类。那么,我们如何能够在WebElement对象中使用WebDriver类的方法呢?

英文:

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

得分: 1

根据Selenium Python绑定文档


结论

因此,driver.find_element(By.ID, 'foo')element.find_element(By.ID, 'foo') 都是有效的代码行。

英文:

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.

huangapple
  • 本文由 发表于 2023年6月12日 23:42:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76458251.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定