当前位置:网站首页>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)')
边栏推荐
- Code skills - Controller Parameter annotation @requestparam
- CUDA中的动态全局内存分配和操作
- DeprecationWarning: .ix is deprecated. Please use.loc for label based indexing or.iloc for positi
- Redis——热点key问题
- 深入了解JUC并发(一)什么是JUC
- TensorRT的数据格式定义详解
- 【张三学C语言之】—深入理解数据存储
- Warp shuffle in CUDA
- LeetCode 40. Combined sum II
- Distributed transactions: the final consistency scheme of reliable messages
猜你喜欢
随机推荐
深入学习JVM底层(四):类文件结构
日志 - 7 - 记录一次丢失文件(A4纸)的重大失误
Redis---1. Data structure characteristics and operation
Does the assignment of Boolean types such as tag attribute disabled selected checked not take effect?
Vector types and variables built in CUDA
Arduino Wire 库使用
MySQL的10大經典錯誤
selenium+msedgedriver+edge浏览器安装驱动的坑
日志(常用的日志框架)
Thread hierarchy in CUDA
FE - weex 开发 之 使用 weex-ui 组件与配置使用
构建学习tensorflow
重载全局和成员new/delete
The difference between session and cookies
链表(线性结构)
Data science [9]: SVD (2)
10 erreurs classiques de MySQL
Detailed definition of tensorrt data format
Sentinel rules persist to Nacos
自学table au









