selenium元素怎么定位

news/2024/7/19 16:39:15 标签: selenium, html, 定位, css, js
htmledit_views">

Selenium对网页的控制是基于各种前端元素的,在自动化过程中,对于元素的定位是基础,只有匹配到对应元素才能进行后续的自动化控制。一共有8种元素定位方式,也可以扩充到18种,只要会用常用的8种就会所有的方法了。


1.根据ID定位

打开浏览器某个网页,按F12键,使用查看器旁边的小箭头点到需要查看的元素,就可以找到相应的元素标签,通过元素标签里面的id进行定位

driver.find_elements_by_id("id名称")

2.根据name定位

driver.find_elements_by_name("name名称")

3.根据Link text定位

driver.find_elements_by_Link_text("text内容")

4.根据Partial Link text定位

find_element_by_partial_link_text

5.根据tag name定位

find_element_by_tag_name

6.根据classname定位

find_element_by_class_name

7.根据xpath定位

find_element_by_xpath

8.根据css选择器定位

find_element_by_css_selector


感谢dalao们的喜欢和关注^-^


http://www.niftyadmin.cn/n/1757354.html

相关文章

阅读笔记:3D Visual Discomfort Predictor: Analysis of Horizontal Disparity and Neural Activity Statistics

题目:三维视觉不适度预测:对水平视差和神经活动的分析 特征:粗特征:双目视差统计;细特征:与水平视差相关联的神经活动 前提:双目融合的实现是通过神经机制,神经反应直接涉及到3D感知…

磕代码:c/c++/java:输入两个整数做运算,输出运算结果,保留两位小数

c: #include<stdio.h> int main() {int a,b;float c,d;scanf("%d %d",&a,&b);/**cb/100;*/cb/100.00;dc*c;printf("%.2f",a/d);/*整型除以整型还是整型*/ }c: #include<bits/stdc.h> using namespace std; int main() {int a,b;cin&…

磕代码:c/c++/Java:输入三角形三边,输出面积,海伦公式

c: #include<stdio.h> int main() {float a,b,c;scanf("%f %f %f",&a,&b,&c);float p(abc)/2.00;float ssqrt(p*(p-a)*(p-b)*(p-c));printf("circumference%.2f area%.2f",abc,s);/*海伦公式p(abc)/2,ssqrt(p(p-a)(p-b)(p-c));*/ }c: …

磕代码:c/c++/java:输入两行大写字母,输出小写字母;用while循环检测输入

c&#xff1a; #include<stdio.h> int main() {char a;while(scanf("%c",&a)!EOF){//EOF每一行结束的标志getchar();//吞掉回车键printf("%c\n",a32);} }c&#xff1a; #include<bits/stdc.h> using namespace std; int main(){char a,b…

磕代码:c/c++/Java:输入整数,输出它的n次方。移位运算符<<的使用

c: #include<stdio.h> int main() {int a;while(scanf("%d",&a)!EOF){getchar();printf("%d\n",2<<a-1);} } //<<移位运算&#xff1b;c&#xff1a; #include<bits/stdc.h> using namespace std; int main() {int a; // …

阅读笔记:3-D Visual Discomfort Assessment Considering Optical and Neural Attention Models

题目&#xff1a;考虑视觉和神经注意模型的3D视觉不适度评估 特征&#xff1a;视网膜视差&#xff1b;V1和MT区域的神经因素&#xff1b; MT区域细胞分类&#xff1a;调节兴奋细胞&#xff1b;调节抑制细胞&#xff1b;调近细胞&#xff1b;调远细胞&#xff1b; 影响舒适度的视…

阅读笔记:3D visual discomfort predictor based on subjective perceived-constraint sparse representation

3D visual discomfort predictor based on subjective perceived-constraint sparse representation in 3D display system 题目&#xff1a;基于主观主观感知约束的稀疏表示的3D不适度预测 SPCSR&#xff1a;主观感知限制的稀疏表示。包括两个阶段&#xff0c;训练阶段&#x…

阅读笔记:Visual comfort assessment for stereoscopic images based on sparse coding with multi-scale dict

Visual comfort assessment for stereoscopic images based on sparse coding with multi-scale dictionaries 题目&#xff1a;基于多尺度稀疏编码字典的立体图像舒适度评价 方法步骤&#xff1a;1.建立舒适度级别的多尺度字典2.估计测试样本属于每个级别的概率3.寻找概率对应…