北京网站改版要注意什么,免费域名,世界十大软件公司排名,海盐建设局网站自动化测试环境#xff1a; Python3.7Selenium3.141谷歌浏览器76.0/火狐浏览器
1、安装Python并配置环境变量。
下载并安装#xff1a;配置环境变量#xff1a;C:\Python37;C:\Python37\Scripts;
2、安装Pycharm开发工具。
下载地址#xff1a; 注意下载#xff1a;Co…自动化测试环境 Python3.7Selenium3.141谷歌浏览器76.0/火狐浏览器
1、安装Python并配置环境变量。
下载并安装配置环境变量C:\Python37;C:\Python37\Scripts;
2、安装Pycharm开发工具。
下载地址 注意下载Community社区版
3、安装Selenium
安装方式一(在线安装)
安装Seleinumpip install -U selenium查看Seleinumpip show selenium卸载Seleinumpip uninstall selenium
安装方式二 Selenium下载地址
安装python包选择全部组件解压selenium-3.13.0.tar.gz然后cmd进入解压目录使用命令 Python setup.py install 安装Selenium
4、安装浏览器Chrome和Firefox的其中之一。
谷歌浏览器火狐浏览器 一般下载延长版
5、浏览器驱动下载Chrome浏览器驱动或者是Firefox浏览器驱动。
Chromedriver谷歌驱动Geckodriver火狐驱动
注意版本需要和对应的浏览器兼容。 下载后解压将exe的文件放到python的目录下如D:\Python37
6、配置webdriver
配置方式一 1把下载好的chromedriver.exe程序放置到python的安装路径下
2把seleinum加入到pycharm的项目中。 Pycharm-File-Setting-Project:项目名-Project Interpreter--搜索selenium-install Package-等10秒
3在python中代码编写如下即可
from selenium import webdriver#打开浏览器driver webdriver.Chrome() #Firefox、le、Edge等
4右击运行能打开浏览器说明自动化测试环境搭建完成。
配置方式二: 1)把下载好的chromedriver.exe程序放置到python项目中其它路径也可 2)在python中代码编写如下即可
chromePath chromedriver.exe #路径os.environ[ webdriver.chrome.driver ] chromePath #gecko 、ie 等driver webdriver.Chrome(executable_pathchromePath) #Firefox、Ie等
如下分别是实现打开谷歌和火狐浏览器并打开百度网址的代码。
#chromechromePath os.getcwd()/../webdriver/chromedriver.exeos.environ[webdriver.chrome.driver]chromePathdriverwebdriver.Chrome(executable_pathchromePath)driver.get(http://www.baidu.com)#firefoxfirefoxPathos.getcwd()/../webdriver/geckodriver.exeos.environ[webdriver.gecko.driver]firefoxPathdriverwebdriver.Firefox(executable_pathfirefoxPath)driver.get(https://www.baidu.com)
selenium自动化测试2023最新的Selenium自动化测试实战没有比这个更详细的了_哔哩哔哩_bilibilihttps://www.bilibili.com/video/BV1xv4y1D7ku/?spm_id_from333.999.0.0