当前位置:网站首页>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()
边栏推荐
- 【GCN-RS】MCL: Mixed-Centric Loss for Collaborative Filtering (WWW‘22)
- 【多模态】《TransRec: Learning Transferable Recommendation from Mixture-of-Modality Feedback》 Arxiv‘22
- There is no sound output problem in the headphone jack on the front panel of MSI motherboard [solved]
- 银行理财子公司蓄力布局A股;现金管理类理财产品整改加速
- Introduction to pl/sql, very detailed notes
- 【云驻共创】AI在数学界有哪些作用?未来对数学界会有哪些颠覆性影响?
- php 一台服务器传图片到另一台上 curl post file_get_contents保存图片
- Transformer变体(Routing Transformer,Linformer,Big Bird)
- brpc源码解析(四)—— Bthread机制
- How to solve the problem that "w5500 chip cannot connect to the server immediately after power failure and restart in tcp_client mode"
猜你喜欢

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

JS流程控制

创新突破!亚信科技助力中国移动某省完成核心账务数据库自主可控改造

微星主板前面板耳机插孔无声音输出问题【已解决】

【RS采样】A Gain-Tuning Dynamic Negative Sampler for Recommendation (WWW 2022)

dirReader. Readentries compatibility issues. Exception error domexception

brpc源码解析(三)—— 请求其他服务器以及往socket写数据的机制

brpc源码解析(六)—— 基础类socket详解

【AI4Code】CodeX:《Evaluating Large Language Models Trained on Code》(OpenAI)

对比学习的应用(LCGNN,VideoMoCo,GraphCL,XMC-GAN)
随机推荐
[multimodal] hit: hierarchical transformer with momentum contract for video text retrieval iccv 2021
JS中的对象
软件缺陷的管理
brpc源码解析(三)—— 请求其他服务器以及往socket写数据的机制
30套中国风PPT/创意PPT模板
JS operator
【高并发】SimpleDateFormat类到底为啥不是线程安全的?(附六种解决方案,建议收藏)
brpc源码解析(八)—— 基础类EventDispatcher详解
Brpc source code analysis (VII) -- worker bthread scheduling based on parkinglot
【AI4Code最终章】AlphaCode:《Competition-Level Code Generation with AlphaCode》(DeepMind)
JS常用内置对象 数据类型的分类 传参 堆栈
JS scope and pre parsing
任何时间,任何地点,超级侦探,认真办案!
Transformer变体(Sparse Transformer,Longformer,Switch Transformer)
[untitled]
已解决The JSP specification requires that an attribute name is preceded by whitespace
Qin long, a technical expert of Alibaba cloud: a prerequisite for reliability assurance - how to carry out chaos engineering on the cloud
【对比学习】Understanding the Behaviour of Contrastive Loss (CVPR‘21)
[GCN multimodal RS] pre training representations of multi modal multi query e-commerce search KDD 2022
JS 面试题:手写节流(throttle)函数