related to href

0 votes
i have to open always 2nd link of any user provided website how can we do that
Jun 14, 2019 in Selenium by Himanshu
• 120 points
569 views

1 answer to this question.

0 votes

Hey Himanshu, as far as I can understand, you want to click the 2nd href link or <a> tag of any website by using Selenium. So you can perform following steps to do that:

  • Navigate to the desired webpage
  • Get list of WebElements with tagname 'a' using driver.findElements()-
    List<WebElement> allLinks = driver.findElements(By.tagName("a"));
  • Now to open the href link, use click() method: 

    allLinks.get(1).click();
answered Jun 18, 2019 by Abha
• 28,140 points

Related Questions In Selenium

+1 vote
1 answer
0 votes
6 answers

How to specify "ENTER" button functionality in Selenium WebDriver code?

using OpenQA.Selenium.Interactions; Actions builder = new Actions(driver); ...READ MORE

answered Feb 13, 2019 in Selenium by anonymous
96,197 views
0 votes
1 answer
0 votes
1 answer

Unable to connect to chromedriver 127.0.0.1:9515 on Amazon Linux AMI server

The issue seems to be only with ...READ MORE

answered Mar 26, 2018 in Selenium by nsv999
• 5,500 points
2,471 views
0 votes
1 answer

Selenium ChromeDriver issue - Want to run it in background, but not as headless browser

This is a flaw with ChromeDriver. Tried ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
8,068 views
0 votes
3 answers

Trying to upload files using Selenium(C#)

You can try using Javascript Executor to ...READ MORE

answered Aug 23, 2019 in Selenium by Abha
• 28,140 points
5,724 views
0 votes
1 answer

Saving data to the same xls file with Robot Framework ExcelLibrary

The documentation of the library states that, ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
6,700 views
0 votes
1 answer

I tried to open a new website when a new tab is opened using Selenium Webdriver

Try this code: ArrayList<String> tabs = new ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
4,443 views
0 votes
1 answer

How to Click a Link by href value in Selenium WebDriver?

Hi Ujjwal, you can use following code ...READ MORE

answered Aug 14, 2019 in Selenium by Abha
• 28,140 points
4,782 views
0 votes
2 answers

Python & Selenium: How to find and click on YouTube's Like button

Hello Nitin, as the Like button on ...READ MORE

answered Aug 23, 2019 in Selenium by Abha
• 28,140 points
5,453 views
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