根据这篇文章进行参考http://t.csdnimg.cn/IlgoK
1、executable_path
若使用executable_path会报该错
driver = webdriver.Chrome(executable_path='chromedriver.exe', options=option)
TypeError: __init__() got an unexpected keyword argument 'executable_path'
解决方法:传入一个Service对象
from selenium.webdriver.chrome.service import Service
service = Service(r'path\chromedriver.exe')
driver = webdriver.Chrome(service=service, options=option)
2、元素定位修改
id = driver.find_element_by_xpath('//*[@id="id"]//tr[1]/td[2]/b')
AttributeError: 'WebDriver' object has no attribute 'find_element_by_xpath'
解决方法:修改后的格式由 driver.find_element_by_方法名(”value”)变为 driver.find_element(By.方法名, “value”), 具体代码为:
from selenium.webdriver.common.by import By
id = driver.find_element(By.XPATH,'//*[@id="id"]//tr[1]/td[2]/b')