当前位置:网站首页>selenium使用———安装、测试
selenium使用———安装、测试
2022-07-25 11:11:00 【时闻折竹】
文章目录
安装selenium
一般情况下,直接使用pip安装即可
pip install selenium
但是如果遇到urllib3的版本冲突问题,需要这样解决
先卸载掉原有的selenium和urllib3
pip uninstall selenium
pip uninstall urllib3
安装特定版本的urlib3
pip install urllib3==1.25.11
安装特定版本的selenium
pip install selenium==4.0.0.a1
配置浏览器驱动
要想selenium能够驱动浏览器进入自动测试模式,需要安装特定浏览器的驱动
确定浏览器的版本
在地址栏输入
chrome://version

进入淘宝镜像进行驱动下载



配置启动环境
将下载的压缩包进行解压,得到一个chromedriver.exe程序(假设该程序的文件路径是:D:\Code\Selenium_Test),需要将该路径配置到环境变量中。
测试
配置好上诉过程后,可以使用如下代码进行测试
from selenium import webdriver
driver = webdriver.Chrome() # 创建一个Chrome的driver实例对象
# 访问页面
driver.get(url="https://www.baidu.com/")
# 搜索网页中id为kw的框,输入xxx
driver.find_element_by_id("kw").send_keys("xxx")
# 搜索网页中id为su的按钮,进行点击
driver.find_element_by_id("su").click()
# 退出
# driver.quit()
边栏推荐
- [imx6ull notes] - a preliminary exploration of the underlying driver of the kernel
- 【GCN】《Adaptive Propagation Graph Convolutional Network》(TNNLS 2020)
- R语言ggpubr包ggarrange函数将多幅图像组合起来、annotate_figure函数为组合图像添加注释、注解、标注信息、fig.lab参数添加图像标签、fig.lab.face参数指定样式
- Transformer变体(Sparse Transformer,Longformer,Switch Transformer)
- winddows 计划任务执行bat 执行PHP文件 失败的解决办法
- Wiznet embedded Ethernet technology training open class (free!!!)
- LeetCode 50. Pow(x,n)
- Go 垃圾回收器指南
- [high concurrency] I summarized the best learning route of concurrent programming with 10 diagrams!! (recommended Collection)
- PHP uploads the FTP path file to the curl Base64 image on the Internet server
猜你喜欢

软件缺陷的管理
![[USB device design] - composite device, dual hid high-speed (64BYTE and 1024byte)](/img/ce/534834c53c72a53fd62ff72a1d3b39.png)
[USB device design] - composite device, dual hid high-speed (64BYTE and 1024byte)

brpc源码解析(四)—— Bthread机制

【AI4Code】《GraphCodeBERT: Pre-Training Code Representations With DataFlow》 ICLR 2021

【Debias】Model-Agnostic Counterfactual Reasoning for Eliminating Popularity Bias in RS(KDD‘21)

GPT plus money (OpenAI CLIP,DALL-E)

30 sets of Chinese style ppt/ creative ppt templates

Power BI----这几个技能让报表更具“逼格“

硬件连接服务器 tcp通讯协议 gateway

【GCN多模态RS】《Pre-training Representations of Multi-modal Multi-query E-commerce Search》 KDD 2022
随机推荐
30套中国风PPT/创意PPT模板
【GCN多模态RS】《Pre-training Representations of Multi-modal Multi-query E-commerce Search》 KDD 2022
JS data types and mutual conversion
JS 面试题:手写节流(throttle)函数
PL/SQL入门,非常详细的笔记
【MySQL 17】安装异常:Could not open file ‘/var/log/mysql/mysqld.log‘ for error logging: Permission denied
[high concurrency] Why is the simpledateformat class thread safe? (six solutions are attached, which are recommended for collection)
【AI4Code】《CoSQA: 20,000+ Web Queries for Code Search and Question Answering》 ACL 2021
微星主板前面板耳机插孔无声音输出问题【已解决】
Return and finally? Everyone, please look over here,
Teach you how to configure S2E to UDP working mode through MCU
Learning to Pre-train Graph Neural Networks(图预训练与微调差异)
Power BI----这几个技能让报表更具“逼格“
LeetCode 50. Pow(x,n)
Introduction to redis
brpc源码解析(一)—— rpc服务添加以及服务器启动主要过程
brpc源码解析(八)—— 基础类EventDispatcher详解
Brpc source code analysis (VI) -- detailed explanation of basic socket
Meta-learning(元学习与少样本学习)
Innovation and breakthrough! AsiaInfo technology helped a province of China Mobile complete the independent and controllable transformation of its core accounting database