第四天 selenium的安装及使用

selenium请求库
1.什么是请求库
selenium是一个自动测试工具,它可以通过代码去实现驱动浏览器自动执行响应的操作
2.为什么要使用selenium?
主要使用selenium的目的是为了跳过登录验证
3.安装与使用
- 下载驱动器
http://npm.taobao.org/mirrors/chromedriver/2.38
- 下载selenium请求库
- 修改下载源为清华源
- D:\python36\lib\site-packages\pip\models\index.py
- PyPI = Index('https://pypi.tuna.tsinghua.edu.cn/simple')
- pip3 install selenium 或settings中安装
from selenium import webdriver
# 驱动浏览器的两种方式
# 第一种直接去Scripts文件夹中查找驱动
# webdriver.Chrome()
# 第二种填写驱动路径
# webdriver.chrome(r'E:\Python\Scripts\chromedriver.exe')
# - 安装谷歌浏览器
# ……
import time
driver=webdriver.Chrome()
time.sleep(5)
driver.close()

猜你喜欢

转载自www.cnblogs.com/requiem/p/11099669.html