当前位置:网站首页>元素定位的八大法则
元素定位的八大法则
2022-06-25 23:54:00 【NitefullSand】
元素定位的八大法则
1.id:类似于人的身份证号码,一般正确的情况下,是不会与其他的标签的id进行重复的。
2.name 人的身份证名字,有可能会出现重复的,如果在定位时遇到多个同样name的标签,则返回第一个name值。
3.class:标签的样式,如input、image等,该方法也是不常用的,因为className内容过多,且存在空格分隔符。所以在定位时容易解析错误。
4.TagName:依据的标签名进行定位,但是在同一页面的标签名存在多个,只在特定情况下进行使用,例如获取表单数据时偶尔会用到。
5.xpath:使用率最高的一种定位方式,类似于文件管理系统的一种定位方式,将元素划分出路径,依据路径对元素定位。
绝对路径:html/body/div/div/span/input
相对路径://*[@id="kw"] (//表示根目录'html',*表示所有元素,@id表示元素有一个id属性,kw表示属性的值)
该方法在IE中,无法很好地支持。
6.CSS selctor 对于仅限于IE浏览器进行的web系统进行元素定位,推荐使用方法。
依据标签的id查找元素:input#su (input表示要查找的元素的标签名,#表示标签的id,su表示元素的属性值)
依据标签的其他属性查找元素:input[name="wd"](input表示要查找的元素的标签名,[name=]表示标签的name属性,wd表示属性的值),
若有多个属性一同查找则使用多个[]表示,例如input[name="wd"][class="s_ipt"]
7.LinkText:专用于定位链接的定位方法。
8.PartiaLinkText:专用于定位链接的定位方法,模糊定位。类似于sql中的like %%
自动化测试:
测试过程中,要选择最合适的方法,最稳定有效的,运行成功率最高的方法进行元素定位。
边栏推荐
- Embedded C first learning notes
- 完整复习(包含语法)--MYSQL正则表达式
- 2021 - 1 - 15 notes de pêche Ctrl + C / V
- MOS管防倒灌电路设计及其过程分析
- Shell regular expression
- What is the process of opening a mobile card account? Is it safe to open an account online?
- Development and monitoring of fusion experiment pulse power supply by LabVIEW
- "Hot post" Statistics
- 《网络是怎么样连接的》读书笔记 - 集线器、路由器和路由器(三)
- SPI protocol
猜你喜欢

SPI protocol

From query database performance optimization to redis cache - talk about cache penetration, avalanche and breakdown

Installing MySQL databases in FreeBSD

Technical foreword - metauniverse

QT cmake pure C code calls the system console to input scanf and Chinese output garbled code

数据分析——切片器、数据透视表与数据透视图(职场必备)

Qt Cmake 纯C 代码调用系统控制台输入scanf 及 中文输出乱码

26. histogram back projection

The overall process of adding, deleting, modifying and querying function items realized by super detailed SSM framework

CityJSON
随机推荐
26. histogram back projection
JSON基本语法
Native DOM vs. virtual DOM
Oracle数据库开启备份准备工作
毕业季你考虑好去留了吗
Etcd database source code analysis cluster communication initialization
JSON简介
Radio boxes are mutually exclusive and can be deselected at the same time
剑指 Offer II 096. 字符串交织
2021 - 1 - 15 notes de pêche Ctrl + C / V
Is it safe to open a fund account? Are there any risks?
生信周刊第34期
15 `bs object Node name Node name String` get nested node content
Common basic Oracle commands
MySQL图书借阅系统项目数据库建库表语句(组合主键、外键设置)
Set set!! Review quickly -- MySQL addition, deletion, modification and query, internal, left and right connection review notes
JSON basic syntax
经纬度 多点 获取中心点 已解决
新库上线 | CnOpenData中国新房信息数据
Is it safe to log in the stock account on the flush? How to open a stock account in the flush