当前位置:网站首页>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(需要上传文件的绝对路径+名字)
边栏推荐
- MySQL free installation download and configuration tutorial
- 文件内容浏览cut、uniq、sort、tr命令的使用,
- Software Testing Interview Questions 2021
- 关于网络安全法的个人理解
- 随机数,函数
- 2021-09-30
- Websocket协议解析与QT代码示例
- 超详细!!!让你通透数组!!!初学复习不迷路!!
- The content of the wangeditor editor is transferred to the background server for storage
- box-shadow相关属性
猜你喜欢
【Latex】TexLive+VScode+SumatraPDF 配置LaTex编辑环境
滑动窗口法
Rejection sampling note
变更管理与 DevOps —— 二者同时进行吗?
Pytorch study notes 10 - detailed explanation of convolutional neural network and application of multi-classification task of mnist dataset
WIN10,配置adb环境
Unity转微信小游戏与JS交互
ImportError: cannot import name 'Xxxx' from partially initialized module 'xx.xx.xx'
crontab timing operation
IDEA overview and installation and debugging
随机推荐
fdisk分区,gdisk添加磁盘,parted进行磁盘分区,parted新增分区,临时挂载和永久挂载
定义一个类,super的使用,私有属性
关于网络安全法的个人理解
顶级程序员都是怎么做的?
IDEA控制台不能输入信息的解决方法
2021-09-30
力扣151. 颠倒字符串中的单词
【内网开发日记】用websocket手搓一个聊天软件
Solution for MySQL The table is full
About iframe
[已解决]ssh连接报:Bad owner or permissions on C:\\Users/XXX/.ssh/config
MW: 3400 4-Arm PEG-DSPE four-arm-polyethylene glycol-phospholipid a saturated 18-carbon phospholipid
随机数,函数
PyTorch Study Notes 08 - Loading Datasets
力扣刷题.快乐数
【Rhapsody学习笔记】3:Dishwasher
DSPE-PEG-Thiol DSPE-PEG-SH phospholipid-polyethylene glycol-thiol liposome for later use
a:自我介绍
【博学谷学习记录】超强总结,用心分享 | 软件测试 UnitTest框架
Software Testing Interview Questions 2021