Skip to content
Advertisement

How to bypass the message-“your connection is not private” on non-secure page using Selenium?

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)?

Advertisement

Answer

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!

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement