Submitted by harrydev on Fri, 10/03/2014 - 05:21
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 :
Submitted by harrydev on Tue, 01/14/2014 - 10:59
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