related to href

0 votes
i have to open always 2nd link of any user provided website how can we do that
Jun 14 in Selenium by Himanshu
• 120 points
28 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 by Abha
• 27,180 points

Related Questions In Selenium

0 votes
1 answer
0 votes
3 answers

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

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

answered Feb 12 in Selenium by anonymous
11,436 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,110 points
582 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 26, 2018 in Selenium by nsv999
• 5,110 points
1,209 views
0 votes
3 answers

Trying to upload files using Selenium(C#)

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

answered Aug 23 in Selenium by Abha
• 27,180 points
1,361 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 26, 2018 in Selenium by nsv999
• 5,110 points
2,055 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,110 points
1,071 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 in Selenium by Abha
• 27,180 points
307 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 in Selenium by Abha
• 27,180 points
706 views