selenium弃用警告DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element()

意思:弃用警告:不推荐使用 find_element_by_* 命令。 请改用 find_element()
原来的写法:

el = web.find_element_by_xpath('//*[@id="changeCityBox"]/p[1]/a')

现在的写法:记得先导入from selenium.webdriver.common.by import By

from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
import time

#创建一个对象
web = Chrome()

web.get("http://lagou.com")

#找到某个元素,点击它
el = web.find_element(By.XPATH,'//*[@id="changeCityBox"]/p[1]/a')
el.click()  #点击事件

这样就解决报错了

你可能感兴趣的:(计算机网络,python,selenium,chrome)