美文网首页
selenium安装相关要点

selenium安装相关要点

作者: 清风昙 | 来源:发表于2022-04-12 00:09 被阅读0次

1.python3安装
https://www.python.org/downloads/windows
配置环境变量
安装python时勾选“Add Python 3.x to PATH””,自动配置环境变量
2.selenium安装

1.cmd环境下
在python安装目录路径Scripts下输入命令安装,如:D:\Programs\Python\Python310\Scripts> pip install selenium
2.下载selenium安装包手动安装
https://pypi.org/project/selenium
选择扩展名为gz的源码包下载以及解压。在Python安装目录找到D:\Program File\Python\Lib\site-packages,新建selenium文件夹,将selenium解压后的文件复制到新建的selenium文件夹。然后通过cmd命令进入到selenium中setup.py所在目录,运行python setup.py install进行安装。

3.安装浏览器驱动driver

chrome: http://chromedriver.storage.googleapis.com/index.html
Edge:https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
IE:http://selenium-release.storage.googleapis.com/index.html
Firefox:http://github.com/mozilla/geckodriver/releases

将下载好的浏览器驱动放置Python安装目录D:\Programs\Python\Python310


image.png

验证浏览器驱动:

from selenium import webdriver
driver = webdriver.Firefox()
driver = webdriver.Chrome()
driver = webdriver.Edge()
driver = webdriver.Ie()
driver.get("http://baidu.com")

pip工具介绍:
pip list 查看安装的包

谷歌浏览器安装chromedriver对应的版本:


image.png

相关文章

网友评论

      本文标题:selenium安装相关要点

      本文链接:https://www.haomeiwen.com/subject/khcgsrtx.html