browse a website using selenium webdriver

0 votes

Is it possible to go through all the URIs of a given website using Selenium WebDriver?
 

I want to launch a Firefox browser using selenium with a given URL of my choice, and then I want the firefox to browse all the pages that website has using Python language.

Jun 8, 2018 in Selenium by DataKing99
• 8,250 points
703 views

1 answer to this question.

0 votes

You can use the below code:

public class BrowseLink {
  
    static List<String> linkAlreadyVisited = new ArrayList<String>();
    WebDriver driver;

    public RecursiveLinkTest(WebDriver driver) {
        this.driver = driver;
    }

    public void linkTest() {
        for(WebElement link : driver.findElements(By.tagName("a")) {
       
            if (link.isDisplayed() 
                        && !linkAlreadyVisited.contains(link.getText())) {
        
                linkAlreadyVisited.add(link.getText());
                System.out.println(link.getText());
             
                link.click();
                
                new RecursiveLinkTest(driver).linkTest();
            }
        }
        driver.navigate().back();
    }

    public static void main(String[] args) throws InterruptedException {
        WebDriver driver = new FirefoxDriver();
        driver.get("https://www.edureka.co/");
        
        new RecursiveLinkTest(driver).linkTest();
    }
}
answered Jun 8, 2018 by Meci Matt
• 9,460 points

Related Questions In Selenium

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,440 views
0 votes
1 answer

Double click a record in a grid using Selenium webdriver

Try Actions class to perform this Actions action ...READ MORE

answered Mar 30, 2018 in Selenium by Damon Salvatore
• 5,980 points
5,356 views
0 votes
1 answer

Select an item from a dropdown list using Selenium WebDriver

Use this then it will work - new ...READ MORE

answered Apr 9, 2018 in Selenium by Vardy
• 2,360 points
7,766 views
0 votes
1 answer

30 min Wait on a page and then perform any Operation using Selenium Webdriver

Implicit wait tells webdriver to poll the ...READ MORE

answered Apr 19, 2018 in Selenium by Shubham
• 13,490 points
3,060 views
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,673 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,142 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,221 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,874 views
0 votes
1 answer
0 votes
1 answer

Is it possible for a website to detect that we are using Selenium with ChromeDriver

Selenium tests for pre-defined javascript variables which ...READ MORE

answered Apr 28, 2018 in Selenium by Meci Matt
• 9,460 points
6,159 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