配置webDriver(Chrome浏览器)

发布时间 2023-12-07 17:18:11作者: jojowei

1. 查看Chrome浏览器版本号

  方法1:Chrome浏览器,设置  >  关于Chrome

 

  方法2: 在Chrome浏览器的地址栏,输入chrome://version/,回车后即可查看到对应版本

 

2. 下载Chrome Driver

  Chrome Driver 下载地址:https://googlechromelabs.github.io/chrome-for-testing/

  下载stable稳定版。

 

       之前版本,下载地址:https://chromedriver.storage.googleapis.com/index.html

 

3.  放置Chrome安装目录下

  解压chromedriver文件,放置python.exe同级目录下。

 

 

4. 安装 selenium 包

    pip install selenium

     (略)

 

 ------------------------------------------------------------------------------------------------------------------

测试成功

  运行代码,可成功打开百度网页。3秒后,网页自动关闭。

 

 
  【测试代码】

  import time
  from selenium import webdriver

  driver = webdriver.Chome()

  driver.implicitly_wait(5)
  driver.get("https://www.baidu.com")

  time.sleep(3)
  driver.quit()