当前位置:网站首页>JS modification element attribute flipping commonly used in selenium's Web Automation
JS modification element attribute flipping commonly used in selenium's Web Automation
2022-07-02 06:33:00 【bthtth】
selenium Can be used in driver.execute_script(script,*args) To execute script Code
One Get elements readonly Property value , And modified to false
# Use selenium To locate elements
target = driver.find_element_by_id("id")
# Write a script : obtain target Elemental readonly The value of the property , And modified to false
# arguments[index] Used for occupying , Will be *args Parameters in replace
script = 'arguments[0].readonly;arguments[0].readonly'
# Put the variable script and target Pass in execute_script()
driver.execute_script(script,target)
Two Scroll screen
1 Scroll the target element to the visible area
# script Provides scrollIntoView() Scroll the target element to the visible area
#scrollIntoView() You can pass in a Boolean parameter . The default is true, Represents scrolling the target element to the top of the visible area ; Pass in false, The target element will be scrolled to the bottom of the region
# 1 Locate the target element
target = driver.find_element_by_id("id")
# Write a script
script = 'arguments[0].scrollIntoView()'
# perform
driver.execute_script(script,target)
2 Scroll the bottom of the page to the area . The usage scenario is : Page not paged , You need to scroll to a certain position before automatically refreshing to get new content
# Scroll the page to the bottom
driver.execute_script('window.scrollTo(0,document.body.scrollHeight)')
# Scroll the page to the top
driver.execute_script('window.scrollTo(document.body.scrollHeight,0)')
边栏推荐
- 【每日一题】—华为机试01
- It is said that Kwai will pay for the Tiktok super fast version of the video? How can you miss this opportunity to collect wool?
- js中正则表达式的使用
- 20201002 VS 2019 QT5.14 开发的程序打包
- Amazon AWS data Lake Work Pit 1
- Codeforces Round #797 (Div. 3) A—E
- Summary of advertisement business bug replay
- Three suggestions for all students who have graduated and will graduate
- 数据科学【九】:SVD(二)
- Android - Kotlin 下使用 Room 遇到 There are multiple good constructors and Room will ... 问题
猜你喜欢
随机推荐
重载全局和成员new/delete
AtCoder Beginner Contest 253 F - Operations on a Matrix // 树状数组
日志 - 7 - 记录一次丢失文件(A4纸)的重大失误
qq邮箱接收不到jenkins构建后使用email extension 发送的邮件(timestamp 或 auth.......)
程序员的自我修养—找工作反思篇
Redis——缓存击穿、穿透、雪崩
压力测试修改解决方案
Sentinel rules persist to Nacos
日期时间API详解
Sentinel Alibaba open source traffic protection component
看完有用的blog
Thread hierarchy in CUDA
广告业务Bug复盘总结
一口气说出 6 种实现延时消息的方案
Pbootcms collection and warehousing tutorial quick collection release
Sentinel规则持久化到Nacos
Redis - hot key issues
automation - Jenkins pipline 执行 nodejs 命令时,提示 node: command not found
Eggjs -typeorm 之 TreeEntity 实战
FE - weex 开发 之 使用 weex-ui 组件与配置使用