This post was most recently updated on June 17th, 2019
To verify page load errors, specific text for thousands of web page it is possible using simple excel Macro.
To perform testing on thousands of URL we can easily use below macro code to verify page load error 404, verification of specific text or any other data validation requirment.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
Sub CheckPageData() Dim cell As Range Dim IntExp As Object Set IntExp = CreateObject("InternetExplorer.Application") IntExp.Visible = True For Each cell In Range("A2", 5) 'Here A2 is cell Address where we have stored urls which we need to test. If Left(cell.Value, 4) = "http" Then ' Goto web page IntExp.Navigate cell.Text ' Below loop will run until page is fully loaded Do Until IntExp.ReadyState = 4 Loop ' Now use text which you want to search , error text which you want to compare etc. If InStr(IntExp.Document.body.innerText, _ "Text which you want to search or verify") > 0 Then cell.Offset(, 1).Value = "Result message which you want to give." Else If InStr(IntExp.Document.body.innerText, _ "The page you requested was not found.") > 0 Then cell.Offset(, 1).Value = "The page you requested was not found." End If End If Next cell IntExp.Quit Set IntExp = Nothing End Sub |