Micro Focus QTP (UFT) Forums
How to Recognize that Browser returns an Error page after hitting a URL with QTP ? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: How to Recognize that Browser returns an Error page after hitting a URL with QTP ? (/Thread-How-to-Recognize-that-Browser-returns-an-Error-page-after-hitting-a-URL-with-QTP)



How to Recognize that Browser returns an Error page after hitting a URL with QTP ? - Sukhvinder - 06-28-2011

I am stuck with one issue with my script. What I am doing is hitting a particular URL fetched from a excel sheet and then checking if this URL is returning a valid response page.
I need to report any error page returned by the browser on any URL hit (it could be 404 or 503). I am unable to get a handle of any error page i.e.
All I need is to identify that the browser has returned an error page and report it in my script, it should not matter whether it returns any error code.
Is there an element on the browser which notifies that an error page is returned which can be captured with QTP script?

Thanking in Anticipation


RE: How to Recognize that Browser returns an Error page after hitting a URL with QTP ? - Skepsis - 06-28-2011

You could capture the text from the page and look for the error number?


RE: How to Recognize that Browser returns an Error page after hitting a URL with QTP ? - Sukhvinder - 06-28-2011

This can be one thing but many a times the error page is formatted to show company specific error messages OR the total look and feel is changed to hold some other message maybe "Sorry, Try again Later" OR "Please try after some time" etc. How to handle such situations ?



RE: How to Recognize that Browser returns an Error page after hitting a URL with QTP ? - supputuri - 06-28-2011

HI,

I would rather check for the desired page or the object in the desired page. As the error message is not specific.



RE: How to Recognize that Browser returns an Error page after hitting a URL with QTP ? - Sukhvinder - 06-29-2011

Hi Supputuri,

The messages are just to explain the issue and not intended to be captured by QTP.

You are right but can you let me know which object on the page I can check for to know anything about the error.


RE: How to Recognize that Browser returns an Error page after hitting a URL with QTP ? - Skepsis - 06-29-2011

If you are sent to an error page then the actual URL will be different from the one expected, so check that. Since this is presumably not a one off test then you will know or can get the list of error urls that the test is going to navigate to as you run through. Just check the URL of the current page against the one expected or against the list of error URLs


RE: How to Recognize that Browser returns an Error page after hitting a URL with QTP ? - Light - 07-01-2011

Hi.

It depends on how you're invoking the URL.

If you're using the "InternetExplorer.Application" approach, then your task becomes very easy. Follow the code below:

Set objIE = WScript. CreateObject("InternetExplorer.Application", "objIE_")

By using this, you've attached a name to the IE object.


Now, you invoke the URL. Also define a Sub like so:

Code:
Sub objIE_NavigateError(pDisp, URL, TargetFrameName, StatusCode, Cancel)
' in case there's been an error, for example, 404 Not Found, then the control would 'reach this place.
MsgBox. "Error: " & StatusCode
End Sub

Let me know if this helped.


RE: How to Recognize that Browser returns an Error page after hitting a URL with QTP ? - rajpes - 07-09-2011

Check if you can use "broken links" option in page check point