当前位置:网站首页>Web automation testing framework realizes the operation of web elements through JS
Web automation testing framework realizes the operation of web elements through JS
2022-04-22 14:55:00 【Chen Xiaoyu I】
selenium Embed the web page we want to automate into his own web page , Then through the script language (js) To perform automated operations
Improve the efficiency and stability of our automated use case execution
- Time calendar Pendant ,js You can get a lot of objects provided by the browser , It provides rich operation methods of page elements , To operate
- Upload files
selenium Difficult operations
- Some hidden buttons , adopt js Change element properties , Show hide button
- Scroll bar
- Front end limit input
js Simple operation

Use driver.execute_script('js Script ') To automate driver.execute_script yes selenium It's a method that comes with it
js object
Browser object ( In developer tools console Input in , Internal width and height : It means removing the menu bar 、 The toolbar 、 After occupation elements such as border , Clear width and height used to display web pages )
window
- window.innerHeight Get the height in the browser
- window.innerWidth Get the inside width of the browser
- window.outerHeight Get browser height
- window.outerWidth Get the width of the browser
- window.open("https://www.baidu.com") Open a new URL
location: Represents the... Of the current page url Information ( A complete url)
- location.href Get the url value
- location.assign("https://www.baidu.com") Load a new url
- location.reload() Reload the current page
document: Object represents the current page . hesitate HTML In the browser DOM In the form of tree structure ,document The object is the whole DOM Root node of tree
- The longest used search is based on ID and Tag Name
- click() Method operation element
- value Attribute assignment realizes keyword input
- readOnly
- textContent Get the text value
- Get element attribute value , Change the attribute value directly
js Application in Automation
Scroll bar ( Because if the page is not fully displayed ,element If it can only be displayed after the drop-down , You can only scroll to this element first click, Otherwise, we can't click)
- window.scrollTo(0,document.body.scrollHeight)
- window.scrollBy(0,document.body.scrollHeight)
- scrollTo:0 Represents the name of the document to be displayed in the upper left corner of the document display area of the window x coordinate ,document.body.scrollHeight Of the document to be displayed in the upper left corner of the document display area of the window y coordinate
- scrollBy:0 Indicates the number of pixels to scroll the document to the right ,document.body.scrollHeight Number of pixels to scroll the document down
Expand
- Non page type scroll bar :scrollTop Method
- Scroll to the specified element :scrollIntoView
- innerHTML
- querySelector
- js obtain cookie
版权声明
本文为[Chen Xiaoyu I]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221446437911.html
边栏推荐
- 阿里云IoT流转到postgresql数据库方案
- Phase I * Chapter IV * general knowledge of project management
- In the second half of the smart watch, opportunities and challenges coexist
- Quickly understand what the dictionary in redis is
- 【 elt.zip】 The Outlook of CCF open source University Bank phase I
- 带你了解极具弹性的Spark架构的原理
- [ELT. Zip] openharmony paper club -- turn over those immortal poems
- [ELT. Zip] openharmony paper Club - you shouldn't miss these small landscapes
- 运输层——无连接运输:UDP(2)
- [ELT. Zip] comments on CCF open source college trip phase I
猜你喜欢

Alibaba cloud IOT transfer to PostgreSQL database scheme

数据库资源负载管理(下篇)

Go language introduction, environment installation, basic structure

干货!对有目标对抗图像迁移性的反思
Android性能优化 _ 帧动画OOM?优化帧动画之SurfaceView逐帧解析,阿里P8面试官都说太详细了

C#安装opencv

集合类

带你了解极具弹性的Spark架构的原理
![[ELT. Zip] openharmony paper club -- counting the compressed bits of life](/img/21/e38c38421b230b8fcf19f955f196ad.png)
[ELT. Zip] openharmony paper club -- counting the compressed bits of life

静态路由综合实验
随机推荐
中国海油上交所上市:市值6515亿 年利润703亿
Leetcode interview question 17.16 Masseur (simple)
View your own system activation type
STM32 saves the collected data in the form of TXT file in the operation practice of SD card. The small single chip microcomputer system can also take out a large amount of local data (SD card + FatFs)
Awk command
Wireguard series (1): what is v * *?
集合类
Redis optimization series (I) building redis master-slave based on docker
2022茶艺师(中级)考试题及答案
[C language] basic concepts of C language
Collection class
Android 面试:事件分发8连问,安卓基础面试题
儿子18岁上大学的时候我们已经60了,给他准备一笔钱买什么理财产品最靠谱?
[ELT. Zip] openharmony paper club -- one article penetrates the forefront of Multimedia
Redis interview question summary, MySQL index optimization, frequently asked interview questions
【C语言】C语言的基本概念
学习记录568@RSA公钥体系及其解密证明方式二
【ELT.ZIP】OpenHarmony啃论文俱乐部——细数生活中的压缩点滴
Is it safe to open a stock account in Nanjing? Is it dangerous?
腾讯云IM集成(so easy)