debug selenium更新后find_element_by_xpath被弃用: Please use find_element(by=By.XPATH, value=xpath)

2022-06-23 10:37:24

问题描述
我在使用edge的webdriver控件时将selenium版本升级了,在升级之前的xpath相关代码是这样的:

driver.find_element_by_xpath('//*[@id="pvExplorationHost"]/div')

更新后xpath也能够找到元素,但会出现弃用警告:

DeprecationWarning:find_element_by_xpath is deprecated. Please usefind_element(by=By.XPATH, value=xpath)

解决方法

from selenium.webdriver.common.byimport By
driver.find_element(By.XPATH,'//*[@id="pvExplorationHost"]/div')
  • 作者:weixin_44127624
  • 原文链接:https://blog.csdn.net/weixin_44127624/article/details/123180976
    更新时间:2022-06-23 10:37:24