Python自动化测试①-Selenium安装

it2023-07-08  67

Python自动化测试①-Selenium安装

1.安装前提

Python3.7

2.Selenium3的安装

(1)使用pip工具安装

pip install selenium #安装

pip install selenium == 3.6.0 #指定安装selenium版本

(2)下载源码安装

https://pypi.org/project/selenium/

python setup.py install

(3)pip常用命令

pip install selenium #安装库文件

pip install -U selenium #安装最新版本号,更新

pip show selenium #查看当前包的版本信息

pip uninstall selenium #卸载selenium

python -m pip install -U pip #升级pip

3.WebDriver的多浏览器测试

注意:浏览器的版本与驱动的版本要一致

1)使用IE浏览器进行测试

http://selenium-release.storage.googleapis.com/index.html

2)FireFox

https://github.com/mozilla/geckodriver/releases/

历史版本:https://ftp.mozilla.org/pub/firefox/releases/

3)Chrome

http://chromedriver.storage.googleapis.com/index.html

http://npm.taobao.org/mirrors/chromedriver/

(5)驱动的用法

1)直接放到已经做过环境变量的目录,比如python37的安装路径下

driver = webdriver.Chrome()

2)放到任意目录下,对该目录进行环境变量的设置

3)驱动位置不固定用法

driver = webdriver.Chrome(executable_path="D:\\driver\\chromedriver")

(6)第一个webDriver脚本

最新回复(0)