当前位置:网站首页>你不可不知道的Selenium 8种元素定位方法,简单且实用
你不可不知道的Selenium 8种元素定位方法,简单且实用
2022-07-06 18:48:00 【小梧敲代码】
自动化最基础的就属于定位元素了,元素不会定位,基本上已经团灭了,就不用再去考虑什么自动化了。
八大定位方法
Selenium定位元素基本上和appium的定位元素方法相同,这里基于百度网站进行测试。
id定位
通过了解HTML可以知道id是唯一表示,通过查找id的方法进行查找
find_element_by_id()
name定位
name在HTML中通常指元素的名称
find_element_by_name()
tag定位
通过HTML可以了解到tag定义不同页面的元素。
find_element_by_tag_name()
class定位
通过HTML了解到class是指元素的类名
find_element_by_class_name()
link_text定位
link_text从字面意思上了解到是通过文本的形式进行定位的
find_element_by_link_text()
partial_link定位
partial_link是属于link_text的补充定位方法,定位一些文本比较长的内容
find_element_by_partial_link_text()
xpath定位
xpath定位有多种定位策略,可以通过很多方法进行定位如:name,text,class等,后面可以单独进行写一篇关于Xpath的定位方法
find_element_by_xpath()
Css_selector定位
Css是一种语言,通常Css定位方法的速度比xpath的快,就是稍微有点难,爬虫中的pyquery就是通过Css的方法来实现的。
find_element_by_css_selector()
简单了介绍了八种定位方法,大家可以在实践中去尝试下,多动手去写代码,才能让代码能力更加熟练。
最后感谢每一个认真阅读我文章的人,下面这个网盘链接也是我费了几天时间整理的非常全面的,希望也能帮助到有需要的你!
这些资料,对于想转行做【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴我走过了最艰难的路程,希望也能帮助到你!凡事要趁早,特别是技术行业,一定要提升技术功底。希望对大家有所帮助……
如果你不想一个人野蛮生长,找不到系统的资料,问题得不到帮助,坚持几天便放弃的感受的话,可以点击下方小卡片加入我们群,大家可以一起讨论交流,里面会有各种软件测试资料和技术交流。
点击文末小卡片领取 |
敲字不易,如果此文章对你有帮助的话,点个赞收个藏来个关注,给作者一个鼓励。也方便你下次能够快速查找。
自学推荐B站视频:
零基础转行软件测试:自学完软件测试,拿到了字节的测试岗offer,堪称B站最好的视频!
边栏推荐
- Untiy文本框的代码换行问题
- 【Unity】升级版·Excel数据解析,自动创建对应C#类,自动创建ScriptableObject生成类,自动序列化Asset文件
- [unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files
- 【论文阅读|深读】ANRL: Attributed Network Representation Learning via Deep Neural Networks
- UC伯克利助理教授Jacob Steinhardt预测AI基准性能:AI在数学等领域的进展比预想要快,但鲁棒性基准性能进展较慢
- 1--新唐nuc980 NUC980移植 UBOOT,从外部mx25l启动
- 投资的再思考
- MFC Windows 程序设计[147]之ODBC数据库连接(附源码)
- [paper reading | deep reading] dngr:deep neural networks for learning graph representations
- 4 -- Xintang nuc980 mount initramfs NFS file system
猜你喜欢
Schedulx v1.4.0 and SaaS versions are released, and you can experience the advanced functions of cost reduction and efficiency increase for free!
FLIR blackfly s usb3 industrial camera: how to use counters and timers
Detailed explanation of line segment tree (including tested code implementation)
Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
Lumion 11.0软件安装包下载及安装教程
Lidar: introduction and usage of ouster OS
C#/VB.NET 删除Word文檔中的水印
3--新唐nuc980 kernel支持jffs2, Jffs2文件系统制作, 内核挂载jffs2, uboot网口设置,uboot支持tftp
【森城市】GIS数据漫谈(二)
The last line of defense of cloud primary mixing department: node waterline design
随机推荐
企业中台建设新路径——低代码平台
C#/VB.NET 删除Word文檔中的水印
Untiy文本框的代码换行问题
Stm32f4 --- PWM output
解密函数计算异步任务能力之「任务的状态及生命周期管理」
Draco - glTF模型压缩利器
New generation cloud native message queue (I)
Summer Challenge database Xueba notes (Part 2)~
Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
Tiflash source code reading (IV) design and implementation analysis of tiflash DDL module
[xlua notes] array of lua to array of C #
Recent applet development records
PCL 常用拟合模型及使用方法
A new path for enterprise mid Platform Construction -- low code platform
unity中跟随鼠标浮动的面板,并可以自适应文字内容的大小
postgresql之整體查詢大致過程
[C # notes] reading and writing of the contents of text files
【Node学习笔记】chokidar模块实现文件监听
3D laser slam: time synchronization of livox lidar hardware
STM32 project -- Topic sharing (part)