selenium+python学习笔记-1(未完待续)
1.使用selenium前首先需要配置好版本一致的谷歌浏览器webdriver,下载地址旧版本:https://chromedriver.storage.googleapis.com/index.html;新版本:https://googlechromelabs.github.io/chrome-for-testing/;
(1)首先win+r,打开cmd,输入chromedriver --version,查看当前chomedriver版本,检查版本一致性
(2)下载对应的版本,解压后放在对应的chrome安装目录下,C:\Users\spencerstirwl\AppData\Local\Google\Chrome\Application;通过where chromedriver查找地址,替换即可
(3)设置环境变量,添加chromedriver.exe的存放路径
2.结合Airtest开始快速编写脚本
(1)通过Airtest录制脚本,运行过程中提示webdriver版本支持chrome119时,将本地webdriver.exe更新到AirtestIDE中即可运行成功,
具体使用教程参见官网https://airtest-refactor.doc.io.netease.com/airtest-project-docs/tutorial/13_Selenium/
(2)将脚本复制到pycharm中,需要安装airtest、selenium相关的库,运行时缺少什么就pip install,完事运行脚本成功
(3)将脚本放到pycharm中运行后,如果提示Exception managing chrome: error sending request for url 远程主机强迫关闭了一个现有的连接;则说明安装的selenium版本不匹配,重新安装换一个版本即可;例如原来的版本是4.11,替换成4.5的即可;运行可成功。
执行安装命令:
pip uninstall selenium
pip install --proxy http://ip:端口 selenium==4.5.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/
3.selenium八大元素定位法
4.增加allure报告
(1)下载安装allure
(2) 修改环境变量
(3)判断是否安装完毕,cmd,输入:allure --version; where.exe allure
(4)

浙公网安备 33010602011771号