您的位置:首页 > Web前端 > CSS

[Selenium] The most commonly used CSSSelector

2015-04-23 14:43 183 查看
CSSSelector

Example

Description

element.element

div.dropdown

Select all <div> elements whose class=“dropdown”

element#element

div#new-input

Select all <div> elements whose id =“new-input”

element element

div p

Select all <p> elements who are under <div> element

element>element

div>p

Select all <p> elements whose father is <div> element

[attribute]

div[rowid]

Select all <div> elements who has attribute rowid

[attribute=value]

input[value='OK']

Select all <input> elements whose attribute value is ‘OK’

[attribute*=value]

a[src*=‘abc’]

Select all <a> elements whose attribute src contains ‘abc’

:nth-child(n)

p:nth-child(2)

Select all <p> elements who is the second child of its father

eg 1: div.rtq-grid-row[rowid] div.rtq-grid-cell:nth-child(5) a

eg 2: div#fileUpDiv input[value='OK']
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: