17

I have some Selenium 2 WebDriver test cases for Firefox and Internet Explorer 9. When I access HTTPS URLs on IE9 (Windows 7 64 bit) I get:

There is a problem with this website's security certificate.

At this point the test hangs and eventually fails.

I tried:

  • Getting Selenium to click on the Continue to this website (not recommended). link. This can't be done as this error page is not your usual page. Same with JavaScript - it doesn't execute.

  • I tried adding the registry key (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_ERROR_PAGE_BYPASS_ZONE_CHECK_FOR_HTTPS_KB954312), that prevents the certificate-error-page from displaying - didn't work. Probably, because I'm on Windows 7 with IE9.

  • Following this advice I tried using BrowserMob proxy, but there's very little documentation out there and I couldn't work it out.

Finally, I don't have admin access to my PC - e.g. no access to group policies. Selenium 2 WebDriver works fine on Firefox. I have all security zones enabled in IE Internet Options and if I run the tests on other URLs (HTTP), then there is no problem.

Has anyone got a solution to this problem?

Does anyone know how to use BrowserMob proxy (or any other proxy) effectively to overcome this issue?

1
  • Did you ever find a solution for this? I have similar issues using watir-webdriver against IE as do others. It seems to be a webdriver issue. caused by something strange about that page. Nov 10, 2011 at 0:12

8 Answers 8

7

There's a couple of solutions depending on how your particular company is set up. The easiest is if the machine that you're running the tests from is on the same domain as the server where the site is hosted. Have the team that manages the server to create a self-signed certificate and have the cert added to your machine. If the self-signed route doesn't work, you'll probably have to have another team involved. If there is someone who is able to issue a certificate from your production certificate authority, have them create and add to your test server. Then, import the certificate to your machine.

Was wrestling with this particular problem for months before our network and infrastructure teams heard about it and offered to help out.

2
  • I'll investigate and let you know how it went. Tried to up-vote you, but I have too few reputation points.. lol. Many thanks.
    – damo_inc
    Oct 11, 2011 at 6:46
  • 2
    Self-signing I have found is the best solution in many of these scenarios, I did get the Security Exception add-ons for FF and IE8 to get around this in my environment. Have yet to try IE9 in my environment but I'm hoping it will be the same.
    – MichaelF
    Oct 11, 2011 at 20:33
7

Try to click the "Continue to this website (not recommended)." link in the following way (works for me on EI7, IE8):

webDriver.navigate().to("javascript:document.getElementById('overridelink').click()");
4

Okay I just got it working under IE9 using C# and the following code:

IWebDriver driver = new InternetExploreDriver();
driver.Url("Site");
driver.Navigate().GoToUrl("javascript:document.getElementById('overridelink').click()");

And now it will go to the real page.

2

I am glad I found this message thread. I must have different version of webdriver and the following line works for me using IE8. Thanks.

    driver.execute_script("document.getElementById('overridelink').click()");

Edited to add: forgot to mention that my driver = webdriver.Ie() !

1
  • Hi Dave - welcome to SQA! I edited to add the info you gave in your second answer - I'll go delete that now otherwise it'll get confusing :)
    – testerab
    Feb 9, 2012 at 22:38
1

I have this code running always when I instance IE8 on my tests. Works fine.

#region SSL workaround for IE
if (driver.GetType() == typeof(InternetExplorerDriver) && driver.Title.Contains("Certificate"))
    driver.Navigate().GoToUrl("javascript:document.getElementById('overridelink').click()");
#endregion
2
  • Isn't the question about IE9, not IE8?
    – corsiKa
    Jul 2, 2013 at 4:46
  • Should work for both.
    – Tedesco
    Jul 2, 2013 at 8:11
0

Yes Rama,

Its the fix for IE8. I have an application which has an expired certificate and I need to accept this certificate to proceed further.

In my framework I have to first navigate to the app's url by driver.get("appurl"), after this SSL error will be thrown. Now to handle this error i have used:

driver.navigate().to("javascript:document.getElementById('overridelink').click()");

This way i was able to resolve this issue for IE8 and IE9 both.

0

Navigate to the site first:

DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
Webdriver driver = new InternetExplorerDriver(capabilities);
driver.get("your testing site");
driver.navigate().to("javascript:document.getElementById('overridelink').click()");
0

For the record, I had similar problem in IE9/Python. That's what worked for me:

if driver.title == 'Certificate Error: Navigation Blocked': driver.get("javascript:document.getElementById('overridelink').click();")

Please note that code above is:

  • not trying to find 'override' element and click on the link (it failed)
  • not trying to execute javascript via driver.execute() method (it failed too)

It sneaks JS to be executed via driver.get() method, and detects (using title) if it needs to be done.

Not the answer you're looking for? Browse other questions tagged or ask your own question.