Friday, February 1, 2013

How to check the website you are testing is up and running

We can check the website up and running by just pinging the website.

You can do that in couple of ways.

Here is the simplest way to  ping a website.

Appraoch1:

strWebSiteName="www.yahoo.com"
strQuery = "SELECT * FROM Win32_PingStatus WHERE Address = '" & strWebSiteName & "'"
bFlag = False

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set objItems = objWMIService.ExecQuery( strQuery )

For Each objItem In objItems
       If objItem.StatusCode = 0 Then
            bFlag = True
            Exit For
        Else
            bFlag = False
        End If
Next

If bFlag = true Then
    print "Website is avilable"
else
    print "Website not avilable"
End If

Set objItems = Nothing
Set objWMIService = Nothing

Appraoch2:
Set oNetwork = DotNetFactory( "Microsoft.VisualBasic.Devices.Network" ,"Microsoft.VisualBasic")
bFlag=oNetwork.ping(strWebSiteName)
If bFlag Then
  print  "Website is avilable"
Else
   print  "Website not avilable"
End If
Set oNetwork=nothing

4 comments:

srikanth said...

the easy way to learn qtp and you covered basic knowledge on qtp . QTP Tutorials

Suseela said...



Awesome article. It is so detailed and well formatted that i enjoyed reading it as well as get some new information too.


Manual testing training in Chennai


Selenium testing training in Chennai

Maani kamili said...

I simply couldn’t depart your site before suggesting that I really enjoyed the usual information an individual supply in your visitors? Is going to be again steadily to check out new posts.

Web development company in Chennai

Thavaselvan said...

How to compare the QTP is explained in a beautiful way. I am thankful for your blog post. QTP Training in Chennai. Thanks for Sahring this blog. Wonderful blog thanks for sharing.