当前位置:网站首页>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)')
边栏推荐
- Kotlin - 验证时间格式是否是 yyyy-MM-dd HH:mm:ss
- Warp shuffle in CUDA
- Golang -- map capacity expansion mechanism (including source code)
- 日志(常用的日志框架)
- In depth understanding of JUC concurrency (II) concurrency theory
- Tensorrt command line program
- MySql索引
- web自动中利用win32上传附件
- Code skills - Controller Parameter annotation @requestparam
- Redis - big key problem
猜你喜欢

分布式事务 :可靠消息最终一致性方案

TensorRT的数据格式定义详解

自学table au

数据科学【八】:SVD(一)

数据科学【九】:SVD(二)

Pbootcms collection and warehousing tutorial quick collection release

Redis - big key problem

Hydration failed because the initial UI does not match what was rendered on the server. One of the reasons for the problem

一口气说出 6 种实现延时消息的方案

注解和反射详解以及运用
随机推荐
FE - Weex 使用简单封装数据加载插件为全局加载方法
Arduino Wire 库使用
Sentinel Alibaba open source traffic protection component
Pbootcms collection and warehousing tutorial quick collection release
FE - weex 开发 之 使用 weex-ui 组件与配置使用
Log (common log framework)
深入了解JUC并发(一)什么是JUC
Mech 3002 explanation
10 erreurs classiques de MySQL
阿里云MFA绑定Chrome浏览器
Hydration failed because the initial UI does not match what was rendered on the server. One of the reasons for the problem
深入学习JVM底层(二):HotSpot虚拟机对象
Detailed definition of tensorrt data format
Codeforces Round #797 (Div. 3) A—E
PgSQL学习笔记
Redis——大Key問題
Alibaba cloud MFA binding Chrome browser
CUDA中内置的Vector类型和变量
稀疏数组(非线性结构)
代码技巧——Controller参数注解@RequestParam