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

python+Visual studio code配置Selenium环境_第1张图片

  • 安装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

你可能感兴趣的:(python+Visual studio code配置Selenium环境)