How to use link as a locator to find element in selenium

0 votes
How can I use Link Text to find the element? I am new to selenium. Can you please help me with this?

Thank you in advance!
Dec 21, 2018 in Selenium by Jino
• 5,820 points
1,810 views

2 answers to this question.

0 votes

Hello @Jino, its amazing to explore ways on how to do things in different way. Using Link text is also another way for finding the method in which you can use the text in the link to click on that link.

So basically you will need to inspect the element and find the text associated and then simply create a reference to it.

Here is how to do this:

As you got the link text then use the following command to click on that :

driver.findElement(By.linkText("Advertising")).click();

Hope this helps.

answered Dec 21, 2018 by Nabarupa
0 votes
driver.findElement(By.linkText("link")).click();
answered Sep 4, 2020 by Sri
• 3,190 points

Related Questions In Selenium

0 votes
2 answers

How can we use JavaScript Executor to click and enter data to a web element in Selenium?

WebElement element = driver.findElement(By.id("abcd")); // Let the ...READ MORE

answered Mar 22, 2020 in Selenium by Lakshmi Sarvepalli
3,515 views
0 votes
5 answers

How to use JavaScript in selenium to click an Element?

WebElement element = driver.findElement(By.id("id")); JavascriptExe ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
70,422 views
0 votes
8 answers

How to open a link in new tab of chrome browser using Selenium WebDriver?

This below code works for me in ...READ MORE

answered Dec 14, 2020 in Selenium by Gitika
• 65,770 points
103,118 views
+4 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,762 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,184 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,257 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,895 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP