问题描述
我在使用edge的webdriver控件时将selenium版本升级了,在升级之前的xpath相关代码是这样的:
driver.find_element_by_xpath('//*[@id="pvExplorationHost"]/div')
更新后xpath也能够找到元素,但会出现弃用警告:
DeprecationWarning:find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value=xpath)
解决方法
from selenium.webdriver.common.by import By
driver.find_element(By.XPATH,'//*[@id="pvExplorationHost"]/div')