A direct child in XPATH is defined by the use of a “/“, while on CSS, it’s defined using “>”
Examples:
1
2
3
|
//div/a
css=div > a
|
If an element could be inside another or one it’s childs, it’s defined in XPATH using “//” and in CSS just by a whitespace
Examples:
1
2
3
|
//div//a
css=div a
|
An element’s id in XPATH is defined using: “[@id='example']” and in CSS using: “#”
Examples:
1
2
3
|
//div[@id='example']//a
css=div
#example a
|
For class, things are pretty similar in XPATH: “[@class='example']” while in CSS it’s just “.”
Examples:
1
2
3
|
//div[@class='example']//a
css=div.example a
|
Thats’ all for now, as you can see, the first rules a pretty simple, and you even make you locators shorter and cleaner.