I want to know if it is possible to get the error code of an HTML page on Ranorex?
My business need is the following one:
- on a web page, I will catch all the <ATag> and put them in a List (or anything else similar).
- For each ATag, I will perform a Click Action and check if the page works.
=> If the page work, I must have a '200 code'
=> If I get an error, I must have a 404, 503, 301 (and so on) error code.
Is it possible to catch such a code? Especially the 200 code?
Get the error code page (ex: 404, 503, 301, 302 etc.)
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Get the error code page (ex: 404, 503, 301, 302 etc.)
Hi,
There is no Ranorex specific method which will achieve this, but as you can use the .Net framework you can get the HTTPStatusCode as follows:
Regards,
Markus
Ranorex Support Team
There is no Ranorex specific method which will achieve this, but as you can use the .Net framework you can get the HTTPStatusCode as follows:
HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(yourATag.Href); HttpWebResponse httpRes = (HttpWebResponse)httpReq.GetResponse(); // you can check the StatusCode of the response if (httpRes.StatusCode==HttpStatusCode...) { // do something } httpRes.Close(); }catch (WebException webEx) { // Now you can access webEx.Response object that contains more info on the server response Report.Info(webEx.Message.ToString()); },this is just a small sample which should show you how it could work.
Regards,
Markus
Ranorex Support Team