其他分享
首页 > 其他分享> > Selenium选择器学习

Selenium选择器学习

作者:互联网

Selenium选择器推荐用CSS选择器

 

If you don’t care about the ordering of child elements, you can use an attribute selector in selenium to choose elements based on any attribute value. A good example would be choosing the ‘username’ element of the form above without adding a class.

We can easily select the username element without adding a class or an id to the element.

 

按照ID:

div#elementId ...

按照属性:
XPATH: //input[@name='username']
CSS: input[name='username']

We can even chain filters to be more specific with our selectors.

XPATH: //input[@name='login'and @type='submit']
CSS: input[name='login'][type='submit']

or选择:用逗号分割即可
css: div.class1,div.class2

 

标签:username,name,Selenium,element,学习,input,选择器,CSS
来源: https://www.cnblogs.com/xiuquan/p/16664559.html