测试积点老人 发表于 2022-1-21 10:00:39

python webdriver 使用异常

以前还可以正常使用,结果一段时间再使用的时候便运行错误,已经更新到最新版本,包卸载重装都不行代码import time
from selenium import webdriver

url = 'https://cy.ncss.cn/information/dsdt?typeCode=CYDS_2TH_DSDT'
brower = webdriver.Chrome()
brower.get(url)

print('666')
brower.find_element_by_xpath("//button").click() #登录
time.sleep(1)

brower.find_element_by_xpath("//label").click() #健康
time.sleep(1)
brower.find_element_by_xpath("//label").click() #是否从学校外出
time.sleep(1)
brower.find_element_by_xpath('//*[@id="post"]').click() #提交
time.sleep(1)
brower.find_element_by_xpath('//a').click() #确认提交无误
time.sleep(1)
brower.quit()    #关闭浏览器异常Traceback (most recent call last):
File "C:\Users\lenovo\Desktop\大创\测试代码1.py", line 16, in <module>
    brower = webdriver.Chrome()
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    service_log_path, service, keep_alive)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 99, in __init__
    options=options)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 268, in __init__
    self.start_session(capabilities, browser_profile)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 359, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 424, in execute
    self.error_handler.check_response(response)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 88
Current browser version is 97.0.4692.71 with binary path C:\Users\lenovo\AppData\Local\Google\Chrome\Application\chrome.exe
Stacktrace:
Backtrace:
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    Ordinal0
    Ordinal0
    Ordinal0
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    GetHandleVerifier
    BaseThreadInitThunk
    RtlGetAppContainerNamedObjectPath
    RtlGetAppContainerNamedObjectPath

qqq911 发表于 2022-1-24 10:15:41

浏览器版本和驱动版本不一致

jingzizx 发表于 2022-1-24 15:33:38

是不是升级导致变更了
页: [1]
查看完整版本: python webdriver 使用异常