Type
Tag and ID
Tag and Class
Tag and Attribute
Tag, Class and Attribute
Starts With
Ends With
Contains
Direct Child
Sub Child
nth Child
Syntax
css=tag#id
css=tag[class='<Value>'] /[Link]
css=tag[attribute='value']
css=[Link][attribute=value]
css=<HTML tag><[attribute^='prefix of the string']>
css=<HTML tag><[attribute$=suffix of the string]>
css=<HTML tag><[attribute*=sub string]>
Tag#parentLocator>childTag
Tag#parentLocator>childTag
css="parentTag#id childTag:nth-of-type(2)"
css="ul#automation li:last-child"
css="ul#automation li:first-child"
Eample
[Link]([Link]("input#Email"))
[Link]([Link]("input[class='inputtext login_form_input_box']"))
[Link]([Link]("input[name='Email']"))
[Link]([Link]("[Link][name=email]"))
[Link]([Link]("input[id^='Em']"))
[Link]([Link]("input[id$='001']"))
[Link]([Link]("input[id*='id']"))
label#loginbutton>input
label#loginbutton>input
css="ul#automation li:nth-of-type(2)" nth Type is used whenall c
nth Type is used whenall children have same attribute values
Type Syntax
Single Attribute //tag[@attribute='attribute_value']
Multiple Attribute //tag[@attribute='attribute_value'][@attribute2='value']
Or Attribute //tag[@attribute='attribute_value' or @attribute2='value']
Contains //tag[contains(@attribute,'value')]
Starts-With //tag[starts-with(@attribute,'prefix')]
index (//tag[contains(@attribute,'value')])[1]
last (//tag[contains(@attribute,'value')])[last()]
last-1 (//tag[contains(@attribute,'value')])[last()-1]
Eample
//input[@id='email']
//input[@id='email'][@data-testid='royal_email']
//input[@id='email' or @data-testid='royal_email']
//input[contains(@data-testid,'royal')]
//input[starts-with(@class,'inputtext')]
(//input[starts-with(@class,'inputtext')])[1] first WebElement
(//input[starts-with(@class,'inputtext')])[last()]
(//input[starts-with(@class,'inputtext')])[last()-1]