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
20 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
• 15,300 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
6,200 views
0 votes
1 answer
0 votes
1 answer

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

Use the CSS Selector button to like: #watch8-sentiment-actions ...READ MORE

answered Mar 26, 2018 in Selenium by nsv999
• 5,050 points
494 views
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,050 points
472 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,050 points
745 views
0 votes
2 answers

Trying to upload files using Selenium(C#)

For uploading file using C# we use ...READ MORE

answered Feb 1 in Selenium by anonymous
740 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,050 points
1,419 views
0 votes
1 answer

How to read a JS variable in Selenium Webdriver?

Hi Himanshu, its quite easy to access any ...READ MORE

answered May 7 in Selenium by Abha
• 15,300 points
89 views
+1 vote
1 answer