美文网首页
selenium与chrome浏览器及驱动的版本匹配

selenium与chrome浏览器及驱动的版本匹配

作者: 可爸 | 来源:发表于2019-05-21 09:47 被阅读0次

    用selenium+python+webdriver完成UI功能自动化,经常会碰到浏览器版本与驱动的版本不匹配而引起报错,下面就selenium与chrome浏览器及驱动的版本匹配 做个总结。

    使用WebDriver在Chrome浏览器上进行测试时,需要先下载与本机chrome浏览器对应的驱动程序,驱动程序名为chromedriver;chromedriver的版本需要和本机的chrome浏览器对应,才能正常使用,具体步骤如下:

    第一步:下载对应版本的chromedriver驱动文件,具体版本请对照文章底部的对应关系表:如本机的chrome浏览器版本为:版本 61.0.3163.100(正式版本) (64 位),对应的chromedriver版本为2.33.

    第二步:下载后把文件解压,然后放到本机chrome浏览器文件路径里,如:C:\Program Files (x86)\Google\Chrome\Application

    第三步:操作完后,就可以使用以下代码直接调起浏览器了:driver =new Chromedriver()

    备注:

    1.chrome历史浏览器下载地址:https://www.chromedownloads.net/

    2.chromedriver下载地址:http://chromedriver.storage.googleapis.com/index.html

    3.环境配置:

    import os #调用系统文件需要应用此包中的方法
    chromedriver = 'C:\Program Files (x86)\Google\Chrome\Application\chromedriver' #指定chromedriver 存放路径
    os.environ["webdriver.chrome.driver"]=chromedriver #配置环境

    4.selenium之 chromedriver与chrome版本映射表:

    image.png
    image.png
    image.png

    相关文章

      网友评论

          本文标题:selenium与chrome浏览器及驱动的版本匹配

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