Finding Elements by Name

Generally ids are put into components once they desire to be recommended from flash or javascript and titles are put into type areas. Whenever referencing component from javascript possibly may be used. From the check automated viewpoint, anytime I-d isn’t accessibleOR functional, you should attempt to make use of the title rather.

Utilizing the identical instance above, the manner in which you might discover the publish switch could be:


There’s one huge difference between your identification and title characteristics although … title characteristics don’t need to be distinctive in a full page. If you will find several components using the identical title, then your initial aspect in the webpage is chosen. Therefore, within this instance, if another switch or type called “login” was existing of additional afterwards, it might trigger the check to crash.

Finding Elements by Text

This locator recognizes hyperlinks from the wording inside them. Let’s take a look at a good example:



<a href=”signin.html”>Sign In</a> to modify your account details.


If you will find several components using wording “Sign In”, the very first one is chosen.

driver.findElement(By.linkText("Sign In"));

Btw, this really is named linkText since it can be used for hyperlinks. In Selenium in the event that you utilized the link=textPattern locator, you could utilize it to find additional components like div, period, td etc. In WebDriver, this locator functions just for hyperlinks.

Another typical situation is whenever we need certainly to discover hyperlinks with a part of the written text it has. In such instances you’ll find it by indicating the partial-text.

For instance:


Leave a Reply

Your email address will not be published. Required fields are marked *