EventHandler subscription

Ask general questions here.
mdgairaud
Posts: 87
Joined: Sun Aug 05, 2012 11:59 am
Location: Bilbao, Spain

EventHandler subscription

Post by mdgairaud » Sun Aug 05, 2012 12:43 pm

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: EventHandler subscription

Post by Support Team » Mon Aug 06, 2012 3:57 pm

Hello MateoDíaz,

Which Ranorex version are you using?

Regards,
Markus
Ranorex Support Team
.
Image

mdgairaud
Posts: 87
Joined: Sun Aug 05, 2012 11:59 am
Location: Bilbao, Spain

Re: EventHandler subscription

Post by mdgairaud » Tue Aug 14, 2012 10:18 am

Hello,

I'm using Ranorex Studio 3.3.1.18483 over Windowx XP


Greetings, MateoDiaz

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: EventHandler subscription

Post by Support Team » Tue Aug 14, 2012 4:15 pm

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
.
Image