Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium 2 Webdriver and IE 9 Security Certificate

Tags:

I have some Selenium 2 Webdriver test cases for Firefox and Internet Explorer 9. When I access https URLs on IE9 (Windows 7 64bit) 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 now hot to use browsermob proxy (or any other proxy) effectively to overcome this issue?

    Thanks, Damo

    like image 454
    damo_inc Avatar asked Oct 10 '11 09:10

    damo_inc


    People also ask

    How will you handle SSL certificate in selenium?

    New Selenium IDE We can handle SSL certificate with Selenium webdriver in Chrome browser. A SSL is the standardized protocol used to create a connection between the browser and server. The information exchanged via a SSL certificate is encrypted and it verifies if the information is sent to the correct server.

    How does selenium handle untrusted certificates?

    Handle Untrusted Certificate SeleniumStep 1-We have to create FirefoxProfile in Selenium. Step 2- We have some predefined method in Selenium called setAcceptUntrustedCertificates() which accept Boolean values(true/false)- so we will make it true. Step 3-Open Firefox browser with the above-created profile.

    Does Selenium support IE 11?

    The Selenium Project will not remove support for IE 11 when it retires but we will not actively fix issues as we have done with previous versions of IE. The Microsoft Edge team have committed to supporting IE Mode in Edge until 2029 when support for Windows 10 is retired.


    2 Answers

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

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

    And now it will go to the intended page. For Java it's as simple as:

    WebDriver driver = new InternetExplorerDriver(); driver.get(YOUR_URL); driver.get("javascript:document.getElementById('overridelink').click();"); 
    like image 175
    Nyegaard Avatar answered Sep 22 '22 19:09

    Nyegaard


    Using the Selenium-Python bindings:

    #region SSL workaround for IE if "Certificate Error" in driver.title:     driver.get("javascript:document.getElementById('overridelink').click();") 
    like image 26
    lacy Avatar answered Sep 21 '22 19:09

    lacy