Many times you may encounter a situation where you are
responsible to test the web application in test environment and need to make
sure that the test environment is up and running.
I have created a simple solution to help you test multiple environments
and collect the results even before you start your work.
Steps to test different environment –
1. Open web browser
2. Enter URL
3. Search web page (Depending on project requirement)
4. Capture result (Pass if webpage loaded)
5. Send out email to all stake holders
We will create a VBS file, and then create a Task in windows
scheduler to run it every morning or whenever it is required
Copy the following code to notepad and save it in
Environment.VBS file-
=================================================
‘This is EnvrionmentTest.VBS
‘This is to test if
all the environments are up and running
Call Main
Function Main
Set IE =
WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate
"https://paragtestingsolutions.blogspot.co.uk"
WScript.Sleep
(1000)
if err.number = 0 then sendEmail (IE.LocationName &
vbCrLf & IE.LocationURL)
End Function
Function SendEmail(eMessage)
strTo= "TestManager@Myorg.uk" 'Enter your managers
email id'
strFrom="myemail@Myorg.uk" 'Enter your email id'
strSubject="Environment Test Results"
strAccountID="myaccountid" 'Enter your email account id
strPassword="myemailpwd" 'Enter your email account password
strSMTPServer="smtp.mailserver.com"
Set oEmail = CreateObject("CDO.Message")
'Message configuration
With oEmail.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= strSMTPServer
.item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")
= 1
.item("http://schemas.microsoft.com/cdo/configuration/sendusername")
= strAccountID
.item("http://schemas.microsoft.com/cdo/configuration/sendpassword")
= strPassword
.Update
End With
'Message Building
With oEmail
.From = strFrom
.To = strTo
.Subject = strSubject
.TextBody = eMessage
End With
' send message
On Error Resume Next
oEmail.Send
If Err Then WScript.Echo "SendMail Failed:" &
Err.Description
End If
wscript.sleep(5000)EndFunction
==================================================
You can store results in a variable for all the
websites and pass it to Send an email as eMessage.
Now windows scheduler –
1. Click on Start => Control Panel
2. Click on System and Security => Administrative tools
=> Task Scheduler
3. Click on Create basic task in action pane
4. Select time to start a program
5. Program/Script Enter “cscript “ and file path
Click on finish.
After this setup you never need to inform about which
environment is up and running. Every morning you will come to know which all
environment are up and running and if anything is not working.
Keep impressing!
No comments:
Post a Comment