当前位置:网站首页>alert弹框处理,div块处理,上传文件
alert弹框处理,div块处理,上传文件
2022-07-31 05:19:00 【欧粒粒】
1.alert弹框的处理
accept 点击确认按钮
dismiss 点击取消按钮
(1)直接关闭
# 定位弹出框/获得弹出框的操作句柄
alert = driver.switch_to.alert()
time.sleep(3)
# 关闭弹出框
alert.accept()(2)输入信息
# 定位弹出框/获得弹出框的操作句柄
alert = driver.switch_to.alert()
time.sleep(3)
# 输入信息
alert.send_keys("夏天")
time.sleep(3)
# 关闭弹出框
alert.accept()
2.div块的处理(适用于页面复杂,元素非常多,没有id且name/tag name重复的情况下)
(1)首先定位元素所在的div模块
(2)在定位到div模块的基础上,去精确寻找这个元素
div1 = driver.find_element_by_class_name("modal-body")
div1.find_element_by_link_text("click me").click()
time.sleep(3)
3.上传文件
定位上传按钮
send_keys(需要上传文件的绝对路径+名字)
边栏推荐
- 2021年开发人员的绊脚石:构建时间长
- vs2022 xlua 集成第三方库编译报错Generator Visual Studio 15 2017 could not find any instance of Visual Studio.
- 文件内容浏览cut、uniq、sort、tr命令的使用,
- Webrtc从理论到实践三:角色
- Software Testing Interview Questions 2021
- 力扣刷题之排序链表
- 滑动窗口法
- 记一次QT 2D 画图 实现3D动态效果
- Remote file xxx is mapped to the local path xxx and can‘t be found. You can continue debugging....
- 这些数组技巧,我爱了
猜你喜欢

CSDN上markdown编写的一些便捷操作

在 AWS 上从零开始设置 Incredibuild 构建系统

Unity导入我的世界模型,简单图解教程(包括调整材质贴图和光照和添加碰撞)

Wangeditor rich text editor to upload pictures and solve cross-domain problems

离线安装activeMq

cenos7安装cmake-3.22.2

ImportError: cannot import name ‘Xxxx‘ from partially initialized module ‘xx.xx.xx‘

Picture-in-Picture API in the browser

Websocket协议解析与QT代码示例

Webrtc从理论到实践二: 架构
随机推荐
Rejection sampling note
MySQL free installation download and configuration tutorial
【内网开发日记】用websocket手搓一个聊天软件
闭包,装饰器,类方法,静态方法,委托属性
Solution for MySQL The table is full
map和set
十分钟教你玩转分支语句!!!!!小白速进,新手福利!!
The solution to the IDEA console not being able to enter information
box-shadow相关属性
DingTalk H5 micro-app login authentication
When solving background-size:cover, the picture is covered but not displayed completely?
力扣刷题之排序链表
Unity版本升级问题总结
vs2022 xlua 集成第三方库编译报错Generator Visual Studio 15 2017 could not find any instance of Visual Studio.
IDEA overview and installation and debugging
Image binarization processing of opencv
数据分析之SQL面试真题
概率论相关笔记
ES6-字符串
IDEA概述和安装及调试