CSS Selector

CSS Selector Attribute

CSS Selectors are available via the Mobilize.QualityMate.Automation.Selectors namespace. Selectors must be set as control attributes:

[Selector("div > span > input")]
public IElement SomeInput { get; set; }

Web Support

All CSS selectors are supported for Web, which can be found on the following W3Schools article.

Desktop Support

The following subset of CSS selectors can be used on Desktop:

SelectorExampleDescription

*

*

Selects all elements.

type

Button

Selects all elements via their control type.

.className

.WinFormsButton

Selects all elements via their class name.

type.className

Button.WinFormsButton

Selects all elements with the control type and class name specified.

#id

#AutomationID

Selects elements via their automation ID.

first, second

Button, Text

Selects all elements that match any selector listed, separated by a comma.

parent descendant

Pane Button

Selects all descendants within a parent element.

parent > child

Pane > Button

Selects all direct children within a parent element.

element ~ sibling

Button ~ Text

Selects all siblings after an element.

element + sibling

Button + Text

Selects all siblings placed immediately after an element.

[property='value']

[Name='ButtonName']

Selects all elements that have the exact property value specified.

[property~='value']

[Name~='ton']

Selects all elements that have a property which contains the value specified.

[property*='value']

[Name|='Button']

Equivalent to [property~='value'].

[property|='value']

[Name|='Button']

Selects all elements that have a property which starts with the value specified.

[property^='value']

[Name^='Button']

Equivalent to [property|='value'].

[property$='value']

[Name$='Name']

Selects all elements that have a property which ends with the value specified.

:nth-child(n)

:nth-child(1)

Selects the element at position n with respect to its siblings. The n value starts at 1.

selector:nth-child(n)

Button:nth-child(1)

Selects the nth element selected by any other selector specified. The n value starts at 1.

Last updated