I have trouble getting the information that provides an event.
the code:
//-----------------------------------------------------------------------------------------
Code: Select all
public void run(string url)
{
foreach (SHDocVw.InternetExplorer iexpl in shellWindows)
{
SHDocVw.InternetExplorer internetExplorer = iexpl;
internetExplorer.NavigateError += new DWebBrowserEvents2_NavigateErrorEventHandler(IeNavigateError);
internetExplorer.Navigate2(url);
}
}
private HttpStatusCode _statusCode;
private void IeNavigateError(object pDisp, ref object URL, ref object Frame, ref object StatusCode, ref bool Cancel)
{
//getting error description
_statusCode = (HttpStatusCode)StatusCode;
//insert into statistics
misEstadisticas.iIDError = int.Parse(StatusCode.ToString());
misEstadisticas.sDescError = _statusCode.ToString();
}
//------------------------------------------------------------------------------------------
How it works:
1. call method 'run' to subscribe the new event and force InternetExplorer to navigate to specified URL
2. if the loaded URL returns an error (404, 402, etc...) it is handled by 'IeNavigateError'
The event must be triggered when an error is detected on the website (Error 404). The problem comes when the event does not fire even though there is an error on the page.
Doing some testing, I found that if the program is run from the IDE Ranorex does not work but if it is run from Visual Studio 2010 or by running the EXE file is working properly. The error is caught and treated properly.
Can it be an error Ranorex IDE or should do some step?
Thank you.
Best regards, MateoDíaz.