selenium元素定位中css或者xpath不选择某一类元素

时间:2022-07-23
本文章向大家介绍selenium元素定位中css或者xpath不选择某一类元素,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

不选择某一类元素,使用

css的写法

:not(属性值)

例如,下列标签中,不选择class为disable的span标签 则 这样写 dd:not(.disabled) > span 或者 dd:not(.disabled) span

xpath的写法

*//dd[not(@class='disabled')]/span