How To Locate Element By Link Text And Partial Link Text Locators

In the previous post we have seen “locators in Selenium“. In this post, we discuss “How To Locate Element By Link Text And Partial Link Text Locators”. Find the below links on How to find elements on a web page using different types of locators.

1. “How To Locate Element By ID Locator
2. “How To Locate Element By Name Locator
3. “How To Locate Element By Class Name Locator
4. “How To Locate Element By Tag Name Locator
5. “How To Locate Element By CSS Selector Locator
6. “How To Locate Element By XPath Locator

Coming to the actual post “How To Locate Element By Link Text and Partial Link Text Locators”.

Link Text Locator:

If there are multiple elements with the same link text then the first one will be selected. This Link Text locator works only on links (hyperlinks) so it is called as Link Text locator.

Syntax:

Locate Element By Link Text And Partial Link Text

Value to be added in the By.linkText method:

Script:

Partial Link Text:

In some situations, we may need to find links by a portion of the text in a Link Text element. it contains. In such situations, we use Partial Link Text to locate elements.

Syntax:

Locate Element By Link Text And Partial Link Text

Value to be added in the By.partialLinkText method:

Script:

Locate Element By Link Text And Partial Link Text

Sumasri is a Sr. Software Test Engineer. Currently working in an MNC. She is a co-founder of Software Testing Material. She has an exclusive experience in the field of Software Testing. She writes here about Manual Testing and Automation Testing.

Leave a Comment

Share via
Copy link
Powered by Social Snap