当前位置:网站首页>Playwright - 滚动条操作
Playwright - 滚动条操作
2022-06-30 19:15:00 【极简之美】
Playwright - 滚动条操作
在页面的操作过程中,多多少少总会遇到对滚动条的操作,本文章主要介绍一下使用自动化工具Playwright操作的两种方式。
一、通过页面元素操作滚动条
1.1 场景说明
在页面中如果元素已经出现了,只是因为滚动条未滚动至下面,所以看不到。在Chrome中可通过F12调试查看页面元素。**而不是元素根本就没有,当滚动时才延迟加载。**可使用此种方式。达到以移动滚动条的目的。
1.2 示例代码
# 页面滚动条,滚动直到此出现元素
page.locator("//div[contains(@class, 'react-grid-item')][last()]")
.scroll_into_view_if_needed()
# 元素说明:找到class里包含‘react-grid-item’属性最后一个属性
二、通过调用鼠标API操作滚动条
2.1 场景说明
在页面中如果有两个滚动条,要操作目标滚动条,首先要使用当前光标移动至滚动条所在框中(div 、iframe等)
2.2 示例代码
# 光标移动至滚动条所在框中
page.click("div.content-main")
# 滚动鼠标 , 参数给一个较大值,以保证直接移动至最后
page.mouse.wheel(0,10000)
边栏推荐
- Whether the SQL is indexed
- 十分之坑,tar命令解压文件的时候竟然不能解析英文括号“()”
- 【多线程】使用线程池、实现一个简单线程池
- SQL continuous login problem
- 闲鱼难“翻身”
- 线上线下双结合,VR全景是家具线上转型好方法!
- Go language learning tutorial (13)
- Is it safe to open an account for mobile phone stock trading!?
- 码蹄集 - MT3435 · 赋值 - 二分图问题 - 图文讲解
- A detailed explanation of the implementation principle of go Distributed Link Tracking
猜你喜欢

项目配置了eslint,编辑器没有关闭eslint功能的情况下,eslint没有生效

8 - 函数

Wechat applets - basics takes you to understand the life cycle of applets (2)
![[multithreading] use the thread pool to implement a simple thread pool](/img/24/ad3ced1d4aebde3f2233b04752bead.png)
[multithreading] use the thread pool to implement a simple thread pool
![[JetsonNano] [教程] [入门系列] [一] 如何开启VNC共享](/img/f5/3f0f69739caa22809f40cf4b7483fe.png)
[JetsonNano] [教程] [入门系列] [一] 如何开启VNC共享

“更福特、更中国”拨云见日,长安福特王牌产品订单过万

RP原型资源分享-购物类App

6-1漏洞利用-FTP漏洞利用

为什么数字化转型战略必须包括持续测试?

A necessary tool for testing -- postman practical tutorial
随机推荐
【LeetCode】【SQL】刷题笔记
一文详解|Go 分布式链路追踪实现原理
Advanced skills of testers: a guide to the application of unit test reports
【NLP】【TextCNN】 文本分类
A detailed explanation of the implementation principle of go Distributed Link Tracking
成长一夏 挑战赛来袭 专属社区福利来袭~免费获得CSDN定制T恤衫
KubeVela 1.4:让应用交付更安全、上手更简单、过程更透明
await和async
ArcGIS no plug-in load (no offset) day map
反射创建实例三种方式(2022.6.6-6.12)
Task04:集合运算-表的加减法和join等--天池龙珠计划SQL训练营学习笔记
Abaqus 2022软件安装包和安装教程
码蹄集 - MT3111· 赋值
Whether the SQL is indexed
A necessary tool for testing -- postman practical tutorial
Go语言学习教程(十三)
FH6908A负极关断同步整流模拟低压降二极管控制IC芯片TSOT23-6超低功耗整流器 1w功耗 <100uA静态 替代MP6908
线下门店为什么要做新零售?
mysql统计账单信息(上):mysql安装及客户端DBeaver连接使用
科大讯飞活跃竞赛汇总!(12个)