Page 1 of 1

EventHandler subscription

Posted: Sun Aug 05, 2012 12:43 pm
by mdgairaud
Hello,

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.

Re: EventHandler subscription

Posted: Mon Aug 06, 2012 3:57 pm
by Support Team
Hello MateoDíaz,

Which Ranorex version are you using?

Regards,
Markus
Ranorex Support Team

Re: EventHandler subscription

Posted: Tue Aug 14, 2012 10:18 am
by mdgairaud
Hello,

I'm using Ranorex Studio 3.3.1.18483 over Windowx XP


Greetings, MateoDiaz

Re: EventHandler subscription

Posted: Tue Aug 14, 2012 4:15 pm
by Support Team
Hello MateoDiaz,

Do you run the Ranorex IDE with the same user privileges as the EXE or the Visual Studio?
Could you send us an Ranorex example project in order to analyze the issue in detail please?

If you don't want to make the project public you can send it to [email protected]

Regards,
Bernhard
Ranorex Support Team