how can you check all the URLS / Links are connected and working correctly throughout the application with the help of scripting in Quick Test Professional Automation tools
Function CheckLinks2 (BrowserObject, BrowserPage) CheckLinks2 = True
sPage = "micclass:=Page" sBrowser = "creationtime:=" Dim orgURL, orgCreationTime Dim i_Link, l_hWnd Dim b_newBrowser Dim s_LinkOuterText, s_LinkInnerText, s_Linkhref
If Trim(BrowserPage.Object.links(i_Link).target) = "" _ And InStr(BrowserPage.Object.links(i_Link).href, "javascript:") = 0 Then b_newBrowser = False Else b_newBrowser = TRUE End If
'Doing Browser.Exist with CreationTime:=1 when the browser does not 'exist will give TRUE so i though of work around to compare the windows 'handle for the old browser and the new browser with CreationTime:=1. 'If they are same that mean no other window was opened. If b_newBrowser Then sBrowser = "CreationTime:=" & i_CreationTime l_newhWnd = CLng(Browser(sBrowser).GetROProperty("hwnd")) If CLng(l_hWnd) = l_newhWnd Then b_newBrowser = False End If End If
On Error Resume Next If b_NewBrowser Then sBrowser = "CreationTime:=" & i_CreationTime Browser(sBrowser).sync Browser(sBrowser).Page(sPage).sync Else BrowserObject.sync BrowserPage.sync End If On Error GoTo 0
Dim s_LinkDetails
If b_NewBrowser Then sBrowser = "CreationTime:=" & i_CreationTime IHTML = Browser(sBrowser).Page(sPage).Object.Body.innerHTML Else IHTML = BrowserPage.Object.Body.innerHTML End If
'Check if page was not able to be displayed you can update this code any time If (InStr(IHTML, "HTTP 404") <> 0) Or (InStr(IHTML, "cannot be displayed") <> 0) Then s_LinkDetails = "Link Broken" + vbCrLf + "Link Details:" + vbCrLf s_LinkDetails = s_LinkDetails + "OuterText: " + s_LinkOuterText + vbCrLf s_LinkDetails = s_LinkDetails + "InnerText: " + s_LinkInnerText + vbCrLf s_LinkDetails = s_LinkDetails + "href: " + s_Linkhref + vbCrLf s_LinkDetails = s_LinkDetails + "Links Open in New Browse: " & bNewBrowser & vbCrLf Reporter.ReportEvent micWarning, "Check Link(" & i_Link & ") -> " & s_LinkOuterText , s_LinkDetails CheckLinks2 = FALSE Else s_LinkDetails = "Link Working" + vbCrLf + "Link Details:" + vbCrLf s_LinkDetails = s_LinkDetails + "OuterText: " + s_LinkOuterText + vbCrLf s_LinkDetails = s_LinkDetails + "InnerText: " + s_LinkInnerText + vbCrLf s_LinkDetails = s_LinkDetails + "href: " + s_Linkhref + vbCrLf s_LinkDetails = s_LinkDetails + "Links Open in New Browse: " & bNewBrowser & vbCrLf Reporter.ReportEvent micPass, "Check Link(" & i_Link & ") -> " & s_LinkOuterText , s_LinkDetails End If
If b_NewBrowser Then sBrowser = "CreationTime:=" & i_CreationTime While CLng(Browser(sBrowser).GetROProperty("hwnd"))<>l_hwnd On Error Resume Next Browser(sBrowser).Sync Browser(sBrowser).Page(sPage).Close On Error GoTo 0 Browser(sBrowser).Close 'Tackle links that open a new browser and also opens a popup using that 'i_CreationTime=i_CreationTime + 1 Wend
i_CreationTime = 1
Else On Error Resume Next BrowserObject.Navigate s_URL BrowserObject.Sync BrowserObject.Page.Sync On Error GoTo 0 End If Next End Function
'********************* In QTP ************** Set BrowserObject = Browser("micClass:=Browser", "CreationTime:=0") Set BrowserPage = BrowserObject.Page("micClass:=Page") CheckLinks2 BrowserObject, BrowserPage '********************************************
Above answer was rated as good by the following members: krisscool
April 05, 2006 06:23:33
Vivek
RE: how can you check all the URLS / Links are connec...
you can use automated tools and websites available to test broken links.Just give the URL of the website and it will generate a report.
RE: how can you check all the URLS / Links are connec...
You can only thoes links which have been connected through that page suppose one link is like when you clik on that link a new uirl has been openedso how can you check
RE: how can you check all the URLS / Links are connec...
hi This is srinivasulu. my answer is only system testing time you can check all the URL is perfectly working or not.
if one project u can connected one url but sub-sequence url so many .
suppose u can take 10 sub url's in one project. Each sub Url is one application once finished testing for all the applications. u test system testing that time we combined all the applications and we did and we find its working or not.
RE: how can you check all the URLS / Links are connec...
Simple task like this should be automated. write perl script and check if a link is valid or not.
Pros:
1. You can even check dynamically created links
2. You can create an exe out of this script and run on any platform without perl installed on it ( please remember this is not portable meaning a windows created exe can be used on 95 98 2k xp....only not on unix. but unix machnied always has perl these days )
RE: how can you check all the URLS / Links are connec...
We can check the number of images links load time using page checkpoint. once a page checkpoint is created after runing script in test analysis pane gives detailed count of links images ..
RE: how can you check all the URLS / Links are connected and working correctly throughout the application with the help of scripting in Quick Test Professional Automation tools
Hi
I heard that various open tool web spiders exist in the market which can crawl the application and check for the broken links in the web application.
Currently I can not access any open source tool so I was thinking is there any way we can do the same job of web spiders or crawlers using QTP.
I have found out that using Page checkpoint in QTP we can know the number of links and there load time with expected urls in the QTP this web page checkpoint also checks for the broken links in the web application.. But somehow when I tried this on the web page its not working fine .
Randomly its showing number of web links as checked and number of then as Not checked under broken link.
here I am not sure of following :-
A) Not checked URL by QTP is really a broken link or not? B) Is it possible to navigate full web application for broken link and url using qtp or its page specific only.
While I am trying to find out the answers to my query by further analyzing the test results I have got …
it would be great if someone can help me with the correct way of doing it If someone has tried this before of QTP
RE: how can you check all the URLS / Links are connected and working correctly throughout the application with the help of scripting in Quick Test Professional Automation tools
Function CheckLinks2 (BrowserObject BrowserPage) CheckLinks2 True
sPage "micclass: Page" sBrowser "creationtime: " Dim orgURL orgCreationTime Dim i_Link l_hWnd Dim b_newBrowser Dim s_LinkOuterText s_LinkInnerText s_Linkhref
If Trim(BrowserPage.Object.links(i_Link).target) "" _ And InStr(BrowserPage.Object.links(i_Link).href "javascript:") 0 Then b_newBrowser False Else b_newBrowser TRUE End If
'Doing Browser.Exist with CreationTime: 1 when the browser does not 'exist will give TRUE so i though of work around to compare the windows 'handle for the old browser and the new browser with CreationTime: 1. 'If they are same that mean no other window was opened. If b_newBrowser Then sBrowser "CreationTime: " & i_CreationTime l_newhWnd CLng(Browser(sBrowser).GetROProperty("hwnd")) If CLng(l_hWnd) l_newhWnd Then b_newBrowser False End If End If
On Error Resume Next If b_NewBrowser Then sBrowser "CreationTime: " & i_CreationTime Browser(sBrowser).sync Browser(sBrowser).Page(sPage).sync Else BrowserObject.sync BrowserPage.sync End If On Error GoTo 0
Dim s_LinkDetails
If b_NewBrowser Then sBrowser "CreationTime: " & i_CreationTime IHTML Browser(sBrowser).Page(sPage).Object.Body.innerHTML Else IHTML BrowserPage.Object.Body.innerHTML End If
'Check if page was not able to be displayed you can update this code any time If (InStr(IHTML "HTTP 404") <> 0) Or (InStr(IHTML "cannot be displayed") <> 0) Then s_LinkDetails "Link Broken" + vbCrLf + "Link Details:" + vbCrLf s_LinkDetails s_LinkDetails + "OuterText: " + s_LinkOuterText + vbCrLf s_LinkDetails s_LinkDetails + "InnerText: " + s_LinkInnerText + vbCrLf s_LinkDetails s_LinkDetails + "href: " + s_Linkhref + vbCrLf s_LinkDetails s_LinkDetails + "Links Open in New Browse: " & bNewBrowser & vbCrLf Reporter.ReportEvent micWarning "Check Link(" & i_Link & ") -> " & s_LinkOuterText s_LinkDetails CheckLinks2 FALSE Else s_LinkDetails "Link Working" + vbCrLf + "Link Details:" + vbCrLf s_LinkDetails s_LinkDetails + "OuterText: " + s_LinkOuterText + vbCrLf s_LinkDetails s_LinkDetails + "InnerText: " + s_LinkInnerText + vbCrLf s_LinkDetails s_LinkDetails + "href: " + s_Linkhref + vbCrLf s_LinkDetails s_LinkDetails + "Links Open in New Browse: " & bNewBrowser & vbCrLf Reporter.ReportEvent micPass "Check Link(" & i_Link & ") -> " & s_LinkOuterText s_LinkDetails End If
If b_NewBrowser Then sBrowser "CreationTime: " & i_CreationTime While CLng(Browser(sBrowser).GetROProperty("hwnd"))<>l_hwnd On Error Resume Next Browser(sBrowser).Sync Browser(sBrowser).Page(sPage).Close On Error GoTo 0 Browser(sBrowser).Close 'Tackle links that open a new browser and also opens a popup using that 'i_CreationTime i_CreationTime + 1 Wend
i_CreationTime 1
Else On Error Resume Next BrowserObject.Navigate s_URL BrowserObject.Sync BrowserObject.Page.Sync On Error GoTo 0 End If Next End Function
'********************* In QTP ************** Set BrowserObject Browser("micClass: Browser" "CreationTime: 0") Set BrowserPage BrowserObject.Page("micClass: Page") CheckLinks2 BrowserObject BrowserPage '********************************************