Page 1 of 1

How can I handle Serurity Alerts

Posted: Tue Apr 22, 2008 8:28 am
by dareim
When the browser switches from http to https (or vica versa) I get a 'Security Alert' popup containig the message:'You are about to view pages over a secure connection' or 'you are about to redirect to a connection that is not secure'.
Ranorex seems somehow blocked, when this message appears.

How can I handle this?

Posted: Tue Apr 22, 2008 9:51 am
by Support Team
The Internet Explorer (IE) process refuses to load the requested site until you click on the 'Yes' or 'Ok' button of the message box. So you need to automate this click using Ranorex:

Code: Select all

Form popup = Application.FindForm("Security Alert", SearchMatchMode.MatchExact, "#32770");
Control yesButton = popup.FindChildText("&Yes");
Mouse.ClickControl(yesButton);
Just add these lines of code below the Mouse.ClickWebElement(...) statement that brings the message box up. You may need to alter the code depending on your IE version (use RanorexSpy to inspect the IE security popup).

Regards,
Alex
Ranorex Support Team

the suggested code is not executed

Posted: Tue Apr 22, 2008 11:03 am
by dareim
I think there is another problem:
The program does not continue, as soon as the security warning appears.
This means, the first line of your suggested code (Form popup = Application...) is never reached.

My environment is: Win2K and XP (I tried both), DotNet 2.0, Visual Studio 2005, C#.

Posted: Tue Apr 22, 2008 2:48 pm
by Support Team
That depends on the method you use to navigate to the unsecure page, whether it blocks the calling thread or not.

If you use Mouse.ClickWebElement(), the code I suggested should work.
Calling WebDocument.Navigate(...), however, blocks the calling thread until the web site is loaded resulting into a deadlock. You can avoid this by calling the WebDocument.Navigate("www.url.com", false) overload. This method overload returns immediately without waiting for the document; ergo, the code clicking onto the security warning will execute.

Regards,
Alex
Ranorex Support Team

Posted: Wed Apr 23, 2008 8:33 am
by dareim
I use Mouse.ClickWebElement() in my code, so this seems not the solution.

There is something else I found,which could probably clarify the situation:
I have an identical effect in your example code (WebTesting.cs). The program works perfect until the picture download (line 182, Mouse.ClickWebElement(image, MouseButtonType.RightButton, Alignment.Center).
Here it stays and the next line (Application.Sleep(1000)) is never called.

Posted: Wed Apr 23, 2008 1:25 pm
by Support Team
Do you use the WebDocument.RunWebAutomation() method?
As this method uses the window thread to run an internal web browser, it is not possible to react on popups (like a message box or context menu). Please use the WebDocument.OpenDocument() method instead!

The WebTesting example should run through provided that you haven't uncommented line 42, which calls RunWebAutomation instead of OpenDocument. Did you do that?

Regards,
Alex
Ranorex Support Team

Posted: Thu Apr 24, 2008 9:15 am
by dareim
I tried now WebDocument.OpenDocument(..) and it works on xp!

On win2000 I get an error (..failed to initialize properly 0x000007b) as soon as WebDocument.OpenDocument(..) is called.

But actually I can continue this evaluation (on xp) and I make progresses!

Thanks for the help & regards

Posted: Thu Apr 24, 2008 11:27 am
by Support Team
Good that it works on Windows XP!

Nevertheless, could you please send us a screenshot of the error on Windows 2000 and the full error message so we can investigate that error in detail. Thanks!

Regards,
Alex
Ranorex Support Team

Posted: Mon Jul 07, 2008 2:58 pm
by Support Team
We have now found a workaround for the WebDocument.OpenDocument() issue on Windows 2000 that will be included in Ranorex V1.5.1.

For more information see this forum entry.

Alex
Ranorex Support Team