cssselector元素定位

轉自https://blog.csdn.net/qq_40024178/article/details/78945651

一.概述

cssSelector也是一種經常使用的選擇器,CSS locator比XPath locator速度快,用CSS Selector能很是精準的定位到想測試的Elementscss

二.cssSelector經常使用符號說明

# 表示idide

. 表示class測試

> 表示子元素,層級spa

一個空格也表示一個子元素,可是全部的子元素至關於xpath中的相對路徑.net

三.cssSelector的經常使用用法

#input 選擇id爲input的節點blog

.Volvo 選擇class爲Volvo的節點input

div#radio>input 選擇id爲radio的div下的全部的input節點it

div#radio input 選擇id爲radio的div下的全部的子孫後代input節點io

div#radio>input:nth-of-type(4) 選擇id爲radio的div下的第4個input節點class

div#radio>nth-child(1) 選擇id爲radio的div下的第1個子節點

div#radio>input:nth-of-type(4)+label 選擇id爲radio的div下的第4個input節點以後挨着的label節點

div#radio>input:nth-of-type(4)~labe 選擇id爲radio的div下的第4個input節點以後的全部label節點

input.Vovlo[name='identity'] 選擇class爲.Volvo而且name爲identity的input節點

input[name='identity'][type='radio']:nth-of-type(1) 選擇name爲identity且type爲radio的第1個input節點

input[name^='ident'] 選擇以ident開頭的name屬性的全部input節點

input[name$='entity'] 選擇以'entity'結尾的name屬性的全部input節點

input[name*='enti'] 選擇包含'enti'的name屬性的全部input節點

div#radio>*.not(input) 選擇id爲radio的div的子節點中不爲input的全部子節點

input:not([type='radio']) 選擇input節點中type不爲radio的全部節點

相關文章
相關標籤/搜索