Handling SSL Certificate Errors in Selenium WebDriver for IE9

Handling SSL Certificate Errors in Selenium WebDriver for IE9

16 July 2024 Stephan Petzl Leave a comment QA

When automating tests using Selenium WebDriver, you might encounter SSL certificate errors, particularly when accessing HTTPS URLs on Internet Explorer 9 (IE9). This issue can cause your tests to hang and eventually fail. Here, we provide a comprehensive guide to resolving this problem effectively.

Understanding the Problem

When Selenium WebDriver tries to access an HTTPS URL, IE9 may display a security certificate error page stating, “There is a problem with this website’s security certificate.” This page is not a typical HTML page, meaning that standard Selenium commands to interact with elements might not work as expected.

Solutions to Bypass SSL Certificate Errors

One of the most effective methods to bypass the SSL certificate error page is to execute JavaScript that clicks the “Continue to this website (not recommended)” link. Here is a practical example:


    WebDriver driver = new InternetExploreDriver();
    driver.get("https://your-secure-url.com");
    driver.navigate().to("javascript:document.getElementById('overridelink').click()");
    

This script navigates to the URL and then executes a JavaScript command to click the override link, allowing the test to proceed.

2. Handling SSL Certificates Using DesiredCapabilities

Another approach involves configuring the WebDriver to accept SSL certificates by setting the appropriate capabilities:


    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    WebDriver driver = new InternetExplorerDriver(capabilities);
    driver.get("https://your-secure-url.com");
    driver.navigate().to("javascript:document.getElementById('overridelink').click()");
    

This method sets up the driver to automatically accept SSL certificates, which can be helpful in bypassing security warnings.

Practical Considerations

These solutions are effective but might require some adjustments based on your specific environment and WebDriver version. Ensure that you test these methods thoroughly to confirm they work as expected in your setup.

Further Reading

Automating Tests Efficiently with Repeato

For those looking to streamline their test automation process, consider using Repeato, a no-code test automation tool for iOS and Android. Repeato leverages computer vision and AI to create, run, and maintain automated tests quickly and efficiently. Its user-friendly interface makes it an excellent choice for quality assurance teams aiming to enhance their testing capabilities without the need for extensive coding knowledge.

Learn more about setting up and using Repeato in our Getting Started guide.

Like this article? there’s more where that came from!