Cuelogic Blog Icon
Cuelogic Career Icon
Home > Blog > All > Handling Certificate errors on Firefox in Selenium

Handling Certificate errors on Firefox in Selenium

Handling Certificate errors on Firefox in Selenium

When we test some sites, we might get SSL Certificate errors and it will be annoying for the Automation testers. They need to manually click on ‘Add Exception’ which doesn’t help when we go for executing Automation regression packs. It is not possible for the tester to click on ‘Add Exception’ button each and every time the certificate error pops up. The reason for getting this certificate error is that RC creates new Firefox profile every time the scripts gets executed.

ssl_certificate_1

We have some workarounds for handling these errors in Firefox and IE.

Firefox:

For Firefox, we have two workarounds.

First Workaround:

When you start your Selenium server, you need to add one parameter -trustAllSSLCertificates which will make your Selenium server as proxy for Firefox browser session. Then, it can easily handle any HTTPS website.

java -jar selenium-server-standalone-2.2.0.jar -trustAllSSLCertificates

Second Workaround: (Tried and worked)

We should not allow Selenium RC to create a new Firefox profile every time. Instead we can create a dedicated profile and ask Selenium RC to use that every time. Follow the below steps:

1) Close all Firefox windows opened.
2) Go to Run and type firefox.exe -ProfileManager -no-remote , press OK. This will open a dialog box
3) Create new Firefox profile, have a name “abc” . You will be prompted to choose a directory for the profile. Save it in C:\profile_name

create_profile

4) Choose that profile and click on Start Firefox.
5) Once Firefox loads, open the page which gives certificate error and add the exception manually.
6) Close your firefox session.
7) Now start the selenium server with the following command:
java -jar selenium-server-standalone-2.2.0.jar -firefoxProfileTemplate C:\profile_name

The server will start with the Firefox profile which you have created. When we execute our scripts, server will launch that Firefox profile.

I have not faced SSL certificate errors while working with webdriver, but a solution for you in case it lands in your life 🙂
insert following command
WebDriver driver = new FirefoxDriver(profile);
in your script. This may solve your problem

Good luck!