-2

How to verify if the invisible web page is loaded or not .
Because of problems in Internet connection or loading the page from the website i get error in display like "the web page can't display" in Internet Explorer for XP or windows 7 or 10 .

Need for way to tell me if web page loaded successfully or have problem so i can decide what is the next step.

hollopost
  • 569
  • 9
  • 28

2 Answers2

0

There is many ways to check if the Web page loaded or you have error from Internet connection problem or the website server

the first way of check is for all version of Internet Explorer for Xp or windows 7 or 10

On Error Resume Next 
'clean the cookies of Internet explorer first
CreateObject("WScript.Shell").Run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2",0,False 
WScript.Sleep 1000

'open the webpage
 Set objIE = wscript.CreateObject("InternetExplorer.Application")
 objIE.visible = 0
 objIE.ToolBar = 0
 objIE.statusbar=0
 objIE.Navigate "http://www.muslimpro.com/Prayer-times-Mecca-Saudi-Arabia-104515"  'change "https" to "http"
    While objIE.Busy Or objIE.ReadyState <> 4 : WScript.Sleep 100 : Wend


'check webpage
If objIE.LocationName=objIE.LocationURL Then
MsgBox "webpage did not loaded try again"
ElseIf objIE.LocationName <> objIE.LocationURL Then
MsgBox "webpage loaded successfully  "
End If

objIE.Quit  
WScript.Quit

Important Note: you have to change in your URL HTTPS to HTTP.

hollopost
  • 569
  • 9
  • 28
0

The second way is :

On Error Resume Next         
'open the webpage
 Set objIE = wscript.CreateObject("InternetExplorer.Application")
 objIE.visible = 0
 objIE.ToolBar = 0
 objIE.statusbar=0
 objIE.Navigate "https://www.muslimpro.com/Prayer-times-Mecca-Saudi-Arabia-104515"
 While objIE.Busy Or objIE.ReadyState <> 4 : WScript.Sleep 100 : Wend

'check webpage        
 webTXT=objIE.Document.Body.innerHTML
myArray=array("The page cannot be displayed","Internet Explorer cannot display the webpage","not connected to a network","notConnectedTasks","errorText","errorCodeAlign")
For Each item In myArray
If  InStr(1,webTXT,item,1)>0  Then
myMsg="Webpage didn't loaded .Try again."
Exit For 
Else 
myMsg="Webpage loaded successfully."
End If 
Next
MsgBox myMsg

objIE.Quit  
WScript.Quit

I used in this way array myArray of error page text display by Internet explorer of xp and windows 7 and 10 and some of id elements inside this error page to show how can you add anything inside the html page to this array ( like tags of id or class names or just text) to check if exist or not.so you know the page load or not.

You can replace myArray values with array of your web page text or Id or Class and check if exist in body of web page IE download or not so you have idea you success load page or not.

hollopost
  • 569
  • 9
  • 28