Tag and ID Tag and Class Tag and Attribute Tag, Class and Attribute Starts With Ends With Contains Direct Child Sub Child
Tag and ID Tag and Class Tag and Attribute Tag, Class and Attribute Starts With Ends With Contains Direct Child Sub Child
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>'] /tag.class
css=tag[attribute='value']
css=tag.class[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
driver.findElement(By.cssSelector("input#Email"))
driver.findElement(By.cssSelector("input[class='inputtext login_form_input_box']"))
driver.findElement(By.cssSelector("input[name='Email']"))
driver.findElement(By.cssSelector("input.inputtext[name=email]"))
driver.findElement(By.cssSelector("input[id^='Em']"))
driver.findElement(By.cssSelector("input[id$='001']"))
driver.findElement(By.cssSelector("input[id*='id']"))
label#loginbutton>input
label#loginbutton>input