当前位置:网站首页>Web automation: how to send JS instructions in 8.2 selenium
Web automation: how to send JS instructions in 8.2 selenium
2022-04-22 08:05:00 【Flower test】
In the last section 8.1 How to send... In the browser js Instructions We learned some common js Instructions .
This section , Continue to study under selenium How to send js Instructions .
Just master this fixed grammar :
driver.execute_script(js_code) # js_code Replace it with what you need js Instructions
for instance : Empty the content of Baidu homepage
from selenium import webdriver
import time
driver = webdriver.Chrome() # Initialize a Google browser
driver.maximize_window() # Maximize browser windows
driver.get("http://www.baidu.com") # Open a Baidu web page
time.sleep(10)
js_code = 'document.body.innerText = ""' # Empty web page
driver.execute_script(js_code)
time.sleep(2)
matters needing attention :
1、 commonly python Code and js Wait a while between the codes , Otherwise, it may be executed before the page is loaded js Code can go wrong .
2、 time.sleep(10) It cannot be replaced by implicit waiting ( Wait until the element appears ); You can use explicit waiting ( etc. url Execute when it is a certain value )
版权声明
本文为[Flower test]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220628391215.html
边栏推荐
- Mysql索引的探索
- js-继承
- SuperSocket在.Net5中使用——WebSocket Server篇
- Postman interface automation-3-tests assertion 3: get dynamic parameters and set environment variables (Interface Association)
- 世平信息亮相中国中医药信息大会,助力医药行业数据安全体系建设
- Help 2021 Hangzhou network security publicity week | collection of wonderful activities of Shiping information
- ik分词器-简单使用
- .NetCore设置API post方式可以直接括号内接受参数
- 杭州市商用密码应用协会领导一行莅临世平信息参观交流
- Supersocket is Used in net5 - appsession and supersocketservice
猜你喜欢

网页导入3D模型-obj/mtl文件

世平信息上榜《CCSIP 2021中国网络安全产业全景图》

Document security notes

Primary test: ordinary vs excellent

世平信息成功通过中国信通院“数据安全类产品能力验证”评测

图解《工业互联网专项工作组2022年工作计划》

实验6 输入输出流

MySql查询指定一行排序到第一行

Help 2021 Hangzhou network security publicity week | collection of wonderful activities of Shiping information

web自动化:8.1如何在浏览器发送js指令
随机推荐
Autoware demo test
Ultra vires and business logic vulnerabilities
web自动化:8.1如何在浏览器发送js指令
行业应用 | 政务大数据平台数据安全合规建设之道
The practical paper of Shiping information and data security compliance testing was selected into the Chinese core journals
Exploration of MySQL index
Shiping information participated in the enterprise roadshow of Hengyang "Chuanshan forum", talked about data security and helped collaborative innovation
Web课设----HIS系统
《数据安全产品指南》正式发布,世平信息多项产品收录其中
Supersocket is Use in net5 - websocket server
How to protect personal information security@ Everyone must not miss this dry goods sharing
在window环境下面virtualbox加载移动硬盘里创建好的虚拟机
web自动化:5.2selenium鼠标操作原理:ActionChains-延时调用
MySQL queries the attributes of all fields in the database
网页导入3D模型-obj/mtl文件
utgard连接opcserver报错Caused by: org.jinterop.dcom.common.JIRuntimeException: Access is denied. [0x800
《数据安全法》解读及安全保密技术应用交流会在京成功举办
How to connect Kunlun on state │ G series screen with Siemens 300 domestic MPI adapter
Flink自定义sink端SinkFunction的应用
世平信息成功通过中国信通院“数据安全类产品能力验证”评测