How can I handle Serurity Alerts

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
dareim
Posts: 14
Joined: Tue Apr 22, 2008 8:19 am

How can I handle Serurity Alerts

Post by dareim » Tue Apr 22, 2008 8:28 am

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?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Tue Apr 22, 2008 9:51 am

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

dareim
Posts: 14
Joined: Tue Apr 22, 2008 8:19 am

the suggested code is not executed

Post by dareim » Tue Apr 22, 2008 11:03 am

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Tue Apr 22, 2008 2:48 pm

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

dareim
Posts: 14
Joined: Tue Apr 22, 2008 8:19 am

Post by dareim » Wed Apr 23, 2008 8:33 am

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Wed Apr 23, 2008 1:25 pm

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

dareim
Posts: 14
Joined: Tue Apr 22, 2008 8:19 am

Post by dareim » Thu Apr 24, 2008 9:15 am

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Thu Apr 24, 2008 11:27 am

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Mon Jul 07, 2008 2:58 pm

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