Skip to content Skip to navigation
Check Our New Demo Website!
Home >> Tags >> Css Examples

Css Examples

Examples with xpath and Css (ID, Name, Text and Links)

As we know it is always better to use ID and Name to locate the elements which will work for sure. You don't need to search for any other locator if there is ID or Name present in your application.

Let us look for xpath examples to use ID and Name effectively with combinations

If the html looks like below :

<input type="text" aria-label="Email or Phone" value="Email or Phone" tabindex="1" placeholder="" name="email" id="email" 
class="inputtext _5aju" style="background-color: transparent;">

We can use as below :

CSS selectors for Selenium with example

When we don't have an option to choose Id or Name, we should prefer using CSS locators as the best alternative.
CSS is "Cascading Style Sheets" and it is defined to display HTML in structured and colorful styles are applied to webpage.

Selectors are patterns that match against elements in a tree, and as such form one of several technologies that can be used to select nodes in an XML document. Visit to know more W3.Org Css selectors

Subscribe to RSS - Css Examples