Book Image

Advanced UFT 12 for Test Engineers Cookbook

Book Image

Advanced UFT 12 for Test Engineers Cookbook

Overview of this book

Table of Contents (18 chapters)
Advanced UFT 12 for Test Engineers Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Checking whether a website is up


This recipe will show you how to check that a site is up, using the XMLHttp object we have seen in action in the Checking whether page links are broken recipe.

Getting ready

We will be using the Web_Functions.vbs function library, seen in the previous recipe, to take advantage of the objXMLHttp global variable, along with the InitXMLHttp() and DisposeXMLHttp() functions. Make sure the library is associated to the test.

How to do it...

Basically, here we will follow the same logic as in the Checking whether page links are broken recipe, but instead of getting the URL from the page links dynamically, we will just pass the URL to the function:

Function checkSiteIsUp(URL)        
    If lcase(typename(oXMLHttp)) <> "xmlhttp" Then    
        initXMLHttp()
    End If
    
    if oXMLHttp.open("GET", URL, false) = 0 then
        oXMLHttp.send()
    
        If oXMLHttp.Status<>200 Then
            reporter.ReportEvent micFail, "Check site is up", "Site ...