際際滷

際際滷Share a Scribd company logo
Locators
for Selenium Automation
BY PRASHANTH SAMS
Locator Types
ID
Name
className
LinkText
Partial LinkText
tagName
CSS
XPath
LOCATORS TYPES ? PAGE 2
CSS Locators
Faster compared to XPath in Internet Explorer due to native
support
Simple statements
CSS3 locators are not advisable as it is JQuery statements
OVERVIEW ? PAGE 3
General
CSS Selectors
ID Selector [#]
#id
Class Selector [.]
.class
.class.class
Descendant combinator [ ]
.class .class
Child Combinator [>]
.class > .class
.class >>> .class
Next or Adjacent Combinator [+]
.class + *
.class + * + *
General Combinator [~]
.class ~ .class
GENERAL ? PAGE 4
Attribute
CSS Selectors
With value
input[type="text"]
Without value
input[type]
Pattern
"[id*='site-map']" --all
"[id~='site-map']" --space sepa..
"[id^='site-map']" --starts-with
"[id$='site-map']" --ends-with
"[id|='site-map']" --hyphen
ATTRIBUTE ? PAGE 5
Multiple attributes
input[type="text"][type="text"]
OR Operator
input[type], input[type]
ATTRIBUTE ? PAGE 6
Text
CSS Locators
Contains
"a:contains(Skip)"
Contains not
"a:contains(Skip):not(asd)"
"a:contains(Skip):not([href='#t'])"
"a:not(:contains(sdf))"
TEXT ? PAGE 7
Pseudo class
:nth()
:nth-child()
:first-child
:last-child
:first-of-type
:last-of-type
:nth-of-type()
:only-of-type
PSEUDO CLASS ? PAGE 8
THANK YOU!
PRASHANTH SAMS
:)
WWW.PRASHANTHSAMS.COM | WWW.SELENIUMWORKS.COM

More Related Content

Css locators