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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。