How to find Broken Links using Cypress
On This Page What are Low Links?Reason for Broken LinksJanuary 12, 2026 · 5 min read · Tool Comparison
Any web covering contains HTML Elements, JavaScript, CSS, etc behind the screen. Generally, the website include the field, buttons, carte items, links, etc. The webpage control multiple pages, and these pages are linked using the HTML link or & lt; a & gt; ticket. For illustration, If you navigate to the BrowserStack home page, you will see menu items, such as SignIn, Product, Pricing, etc. These are menus internally linked to their respective pages to make a smooth user experience. The links are the almost crucial portion as they provide piloting across the website. The broken link determine the user ’ s access to specific web pages. The web coating contains century of tie on each page, and manually testing every link is difficult. What are Humiliated Links? Steps to Automate Broken Link Checks in Cypress This article will give an overview on how to identify and care broken links expend Cypress. A humbled connection is a web page that can not be establish or access by the user. The broken links are too ring Dead links. The web servers often return error message or mistake codes for humiliated links. This normally pass because the website or particular web page is down or does not be. When mortal snap on a broken link, an mistake message is displayed. If the URL is giving any code between 400 to 599 (client or server) can be considered as a humbled link. is the most effective test automation tool that can be used for testing broken link scenario. Once you write the Cypress exam, the mechanization tryout can be run on a scheduled foundation to check the low links. There are two method to regain the broken links in Cypress Let & # 8217; s consider a scenario, you have a web page and you desire to find all the crushed links on that page. This scenario can be automated using Cypress. Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script. Read More: Steps to Find all broken links on a Webpage You can compose the Cypress automation script to execute the above steps, and you can find all the broken nexus on the webpage. Cypress Test to Find the Broken Link Let & # 8217; s understand the above code, cy.visit ():Navigating to the webpage cy.get (& # 8216; a & # 8217;, {failOnStatusCode: false}):Using cy.get (& # 8216; a & # 8217;) we are fascinate an element which is having tag & lt; a & gt;. The & lt; a & gt; tag moderate urls. The .each()command to used to iterate over the each tie cy.request ()is used for requesting each URL The failOnStatusCode: false:option is employ while requesting the URL. Cypress fails the examination by nonremittal if any request revert the 4XX HTTP codes. Since our use-case is to find all the broken links by iterating over them one by one we don & # 8217; t need the test case to fail. When you fulfill the above trial, you can see the output as shown below. You can see that in the above effect the URLs regress with status code 4XX are tag with a red band which intend that those URLs are not ground or broken. Consider another scenario where you get a set of tie-in ready or stored in the file, you need to insure often. This can be done using Cypress. List of links store in links.json file Cypress code to test the links Let & # 8217; s understand the above code: cy.fixture (& # 8216; links & # 8217;):The Cypress fixture provide functionality to read the datum from the .json file. for (var index in data):Using the for each iteration iterate over all the links in .json file cy.request:Use the cy.request () bid to request the URL Execution output of Cypress test In the above effect, we can see that the URL https: //browserstack.com/notfound has returned the condition codification 400 which is the URL is invalid or broken. Cypress validates the crushed links faster compared to any other tryout framework. The cy.request () command doesn & # 8217; t perform page loading; rather it merely sends the HTTP request to the specified URL and have the reply. Since there is no motivation to furnish all the Visual elements, the cy.request () is quicker. This method helps to find the thousands of URL act states either working or broken. Closing Notes As mentioned before the link may not be reachable due to assorted reasons, such as the page being moved, deleted, or geographic restrictions. One of the near difficult scenarios to chance the low link is testing the low link due to its geographical restrictions. # Ask-and-Contributeabout this theme with our Discord community. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.How to find Broken Links use Cypress
Overview
What are Broken Links?
Reason for Broken Links
HTTP Error Codes
How to find the Broken Links using Cypress?
Find Broken Links in the Webpage using Cypress
//broken-link.cy.js describe ('Broken Link ', () = & gt; {beforeEach (() = & gt; {cy.viewport (1280, 1000)}) it ('Find all broken links ', () = & gt; {cy.visit ('https: //www.tic.com/ ') cy.get (' a ') .each (relate = & gt; {if (link.prop ('href ')) cy.request ({url: link.prop ('href '), failOnStatusCode: mistaken}) cy.log (link.prop ('href '))})})})Testing Broken Links in Cypress with a List of URLs
[{'' url '': `` https: //gooogle.com ''}, {'' url '': `` https: //gooogle.co.in ''}, {'' url '': `` https: //yahoo.com ''}, {'' url '': `` https: //browserstack.com/notfound ''}]//broken-link1.cy.js describe ('Broken link ', () = & gt; {it ('should verify links ', () = & gt; {cy.fixture ('links ') .then ((data) = & gt; {for (var index in data) {cy.log (data [index] .url) cy.request ({url: data [indicator] .url, failOnStatusCode: false})}})})})Related Guides
Automate This With SUSA
Test Your App Autonomously