美文网首页测试那些事儿
Selenium调用Google浏览器遇到的坑

Selenium调用Google浏览器遇到的坑

作者: 极客与宽客 | 来源:发表于2019-03-19 13:52 被阅读10次

    调用chrome

    driver = webdriver.Chrome(chrome_driver_path)

    driver.implicitly_wait(30)

    driver.maximize_window()

    报错信息

    selenium.common.exceptions.WebDriverException: Message: Service C:\Program Files (x86)\Google\Chrome\Application\chrome.exe unexpectedly exited. Status code was: 0

    原因:

    1、首先保证添加正确的chrome_driver_path

    dir ='C:\Program Files (x86)\Google\Chrome\Application'  # os.path.dirname(__file__)

    chrome_driver_path = dir +'\chromedriver.exe'

    2、保证在dir 中存在chromedriver.exe

    下载地址:https://sites.google.com/a/chromium.org/chromedriver/downloads

    下载对应版本号:打开chrome浏览器,选择设置->帮助->关于chrome,查看自己浏览器的版本

    将chromedriver.exe保存到dir中,重新运行

    Success

    相关文章

      网友评论

        本文标题:Selenium调用Google浏览器遇到的坑

        本文链接:https://www.haomeiwen.com/subject/ekegmqtx.html