18

I'm trying to interact with the page "Your connection is not private".

The solution of using options.add_argument('--ignore-certificate-errors') is not helpful for two reasons:

  1. I'm using an already open window.
  2. Even if I was using a "selenium opened window" the script runs non stop, and the issue I'm trying to solve is when my browser disconnects from a splunk dashboard and I want it to automatically connect again(and it pops the private connection window).

How do I click on "Advanced" and then click on "Proceed to splunk_server (unsafe)?

Seanny123
  • 8,776
  • 13
  • 68
  • 124
Gil Kor
  • 314
  • 1
  • 2
  • 9

4 Answers4

41

For chrome:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument('--ignore-ssl-errors=yes')
options.add_argument('--ignore-certificate-errors')
driver = webdriver.Chrome(options=options)

If not work then this:

from selenium import webdriver
from selenium.webdriver import DesiredCapabilities

options = webdriver.ChromeOptions()
options.add_argument('--allow-insecure-localhost') # differ on driver version. can ignore. 
caps = options.to_capabilities()
caps["acceptInsecureCerts"] = True
driver = webdriver.Chrome(desired_capabilities=caps)

For firefox:

from selenium import webdriver

profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True

driver = webdriver.Firefox(firefox_profile=profile)
driver.get('https://cacert.org/')

driver.close()

If not work then this:

capabilities = webdriver.DesiredCapabilities().FIREFOX
capabilities['acceptSslCerts'] = True
driver = webdriver.Firefox(capabilities=capabilities)
driver.get('https://cacert.org/')
driver.close()

Above all worked for me!

Sayed Sohan
  • 1,385
  • 16
  • 23
  • Do you happen to know a way to do this for Edge (Chromium)? – schneida Dec 18 '20 at 11:27
  • @schneida sorry, I didn't work with edge so can't tell. But I think as Edge use chromium engine so program for chrome browser should work. – Sayed Sohan Dec 20 '20 at 14:09
  • 1
    I was thinking Edge would use the same parameters as chromium, but I tried it and that didn't work. I ended up using Selenium automation itself to click the continue button on the privacy page... Works fine – schneida Dec 28 '20 at 14:29
  • `edgeOptions = new EdgeOptions().merge(chromeOptions);driver = new EdgeDriver(edgeOptions);` something like this works.. you can try it. – Sayed Sohan Dec 29 '20 at 09:58
  • the code for Chrome isn't valid python code – rok Jun 25 '21 at 11:26
  • @rok Thanks for checking out. I am editing it. – Sayed Sohan Jun 25 '21 at 12:49
  • options.add_argument('--ignore-ssl-errors=yes') options.add_argument('--ignore-certificate-errors') Works fine. – muthukumar Apr 06 '23 at 06:50
1

This is how i handle this problem:

import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.CapabilityType;

ChromeOptions capability = new ChromeOptions();
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capability.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS,true);

WebDriver driver = new ChromeDriver(capability);
0

This chrome option is the silver bullet for me:

 chromeOptions.addArguments("--allow-running-insecure-content");

If you need more, Open chrome & paste this URL:

        chrome://flags/

One will find all the options and their impact on the chrome.

Atul KS
  • 908
  • 11
  • 21
0

Either of below 2 solutions worked for me using Python Chrome Selenium Webdriver:

from selenium import webdriver
from selenium.webdriver import DesiredCapabilities

capabilities = DesiredCapabilities.CHROME.copy()
capabilities["acceptInsecureCerts"] = True
driver = webdriver.Chrome(desired_capabilities=capabilities)

And accepted solution:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument('--ignore-ssl-errors=yes')
options.add_argument('--ignore-certificate-errors')
driver = webdriver.Chrome(options=options)
rok
  • 9,403
  • 17
  • 70
  • 126