Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

0
Do anyone know any tool in which we get broken links of the site?

Open 3 Answers 65 Views
0 3
Do anyone know any tool in which we get broken links of the site but the site has authentication ie username and password?

I tried with Xenu, Link checker but that does not work.
1Comments
commented by (52 points)
Xenu link checker tool. It is open source and free tool.

3 Answers

1
1
https://en.softonic.com/download/xenus-link-sleuth/windows

This is Xenu link checker tool. easy and effective tool.
answered by (52 points)
0
0
Have you tried

https://www.screamingfrog.co.uk/seo-spider/

Screaming Frog SEO Spider? That lets you find broken link.
answered by
-1
-1
I have  done broker link in selenium web driver and find all link which are broken and also get http codes
answered by (748 points)
2Comments
commented by (552 points)
Can you provide little more idea of how you did that?
commented by (748 points)
package selenium;

import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class FindBrokenLinkExample {
   
    private WebDriver driver;
    private int invalidLinksCount;

    @BeforeClass
    public void setUp() {
        System.setProperty("webdriver.firefox.marionette","E://Users//Bharat Varshney//workspace//drivers//geckodriver.exe");
        driver = new FirefoxDriver();
        driver.manage().window().maximize();
        driver.get("http://google.com");
    }

    @Test
    public void validateInvalidLinks() {

        try {
            invalidLinksCount = 0;
            List<WebElement> anchorTagsList = driver.findElements(By .tagName("a"));
                   
            System.out.println("Total no. of links are "+ anchorTagsList.size());
                   
            for (WebElement anchorTagElement : anchorTagsList) {
                if (anchorTagElement != null) {
                    String url = anchorTagElement.getAttribute("href");
                    if (url != null && !url.contains("javascript"))
                    {
                        verifyURLStatus(url);
                       
                    } else
                    {
                       
                        invalidLinksCount++;
                    }
                }
            }

            System.out.println("Total no. of invalid links are " + invalidLinksCount);
                   

        } catch (Exception e)
        {
            e.printStackTrace();
            System.out.println(e.getMessage());
        }
    }

    @AfterClass
    public void tearDown() {
        if (driver != null)
            driver.quit();
    }

    public void verifyURLStatus(String URL) {

        HttpClient client = HttpClientBuilder.create().build();
        HttpGet request = new HttpGet(URL);
        try {
            HttpResponse response = client.execute(request);
            // verifying response code and The HttpStatus should be 200 if not,
            // increment invalid link count
            ////We can also check for 404 status code like response.getStatusLine().getStatusCode() == 404
            if (response.getStatusLine().getStatusCode() != 200)
                invalidLinksCount++;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...