Forum Discussion

salley's avatar
salley
Frequent Contributor
7 years ago

Checking for Valid or broken links

Hello, I've a  large number of links present in a page, and i'm trying to verify if they're valid or broken. My accessiblity check point doesn't work, Test Complete Freezes not sure why. i've tried...
  • shankar_r's avatar
    shankar_r
    7 years ago

    I would use TestComplete in-built option called aqHttpRequest 

    Sample code:

     

    function checkLink(URL)
    {
      var address = URL;
    
      var aqHttpRequest = aqHttp.CreateGetRequest(address);
    
      // Send the request, get an aqHttpResponse object
      var aqHttpResponse = aqHttpRequest.Send(); 
      
      // Read the response data
      Log.Message(aqHttpResponse.AllHeaders); // All headers
      Log.Message(aqHttpResponse.GetHeader("Content-Type")); // A specific header
      Log.Message(aqHttpResponse.StatusCode); // A status code 
      Log.Message(aqHttpResponse.StatusText); // A status text 
      Log.Message(aqHttpResponse.Text); // A response body     
    }