python+Visual studio code配置Selenium環境

python+Visual studio code配置Selenium環境

使用pip命令安裝selenium

Visual studio code控制檯中直接輸入:

python -m pip install selenium

clipboard.png

  • 查看是否安裝selenium成功

Visual studio code中直接輸入:

pip show selenium

clipboard.png

  • 安裝ChromeDriver、Firefox Geckodriver

https://sites.google.com/a/ch...
https://github.com/mozilla/ge...

將chromedriver.exe、geckodriver.exe放在python安裝目錄,或將chromedriver.exe所在目錄添加到環境變量path中

  • 檢查Selenium+python+Visual studio code是否配置成功
# coding:utf-8
from selenium import webdriver
# 創建Firefox對象
# driver = webdriver.Firefox()
driver = webdriver.Chrome()
driver.get('https://cn.bing.com/')
driver.quit()

F5運行代碼,打開https://cn.bing.com/,配置成功

版本

  • python版本3.6.4

    PS D:\Python\selenium> python
       Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
       Type "help", "copyright", "credits" or "license" for more information.
    
  • Selenium版本3.141.0

       PS D:\Python\selenium> pip show selenium
       Name: selenium
       Version: 3.141.0
       Summary: Python bindings for Selenium
       Home-page: https://github.com/SeleniumHQ/selenium/
       Author: UNKNOWN
       Author-email: UNKNOWN
       License: Apache 2.0
       Location: c:\programs\python\python36-32\lib\site-packages
       Requires: urllib3
       Required-by:  
    
  • Chrome版本 70.0.3538.77(正式版本) (64 位)
  • ChromeDriver版本2.43
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章