当前位置:网站首页>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)')
边栏推荐
猜你喜欢
Redis——Cluster数据分布算法&哈希槽
日期时间API详解
CUDA中的Warp Shuffle
Cglib agent - Code enhancement test
Hydration failed because the initial UI does not match what was rendered on the server. One of the reasons for the problem
Redis——大Key問題
Detailed definition of tensorrt data format
实现strStr() II
栈(线性结构)
Sparse array (nonlinear structure)
随机推荐
Hydration failed because the initial UI does not match what was rendered on the server.问题原因之一
Does the assignment of Boolean types such as tag attribute disabled selected checked not take effect?
Find the highest value of the current element Z-index of the page
最新CUDA环境配置(Win10 + CUDA 11.6 + VS2019)
Idea announced a new default UI, which is too refreshing (including the application link)
DeprecationWarning: .ix is deprecated. Please use.loc for label based indexing or.iloc for positi
Function execution space specifier in CUDA
计算属性普通函数写法 和 set get 写法
Storage space modifier in CUDA
Thread hierarchy in CUDA
Redis——大Key问题
Singleton mode compilation
web自动化切换窗口时报错“list“ object is not callable
In depth understanding of JUC concurrency (I) what is JUC
压力测试修改解决方案
The Chinese word segmentation task is realized by using traditional methods (n-gram, HMM, etc.), neural network methods (CNN, LSTM, etc.) and pre training methods (Bert, etc.)
Alibaba cloud MFA binding Chrome browser
RestTemplate请求时设置请求头,请求参数,请求体。
华为MindSpore开源实习机试题
Common means of modeling: combination