1

How do you disable Chrome's verification of self-signed SSL certificate?

I'm trying to unittest a mobile web app using Selenium in Python. Because it accesses the browser's microphone, it has to use https, even if it's just an ad-hoc or self-signed certificate.

However, when Selenium loads the initial page, it gets that warning page, "Your connection is not private", with the "Advanced" button menu you have to navigate in order to override the error.

Is there anyway to override this or do I always have to prefix my tests with?

driver.find_element_by_id('details-button').click()
driver.find_element_by_id('proceed-link').click()

Also, even if I click the appropriate buttons to override, my test still needs to click the "Allow" when it prompts the user for microphone access. However, since that's not a web element, there's no way for Selenium to click that? Is there any config option to disable and auto-approve that access?

Cerin
  • 60,957
  • 96
  • 316
  • 522
  • I can't help with disabling this verification, but if you need it for testing and can live with a slight discomfort, you can use selenium (it opens the browser and clicks whatever you need) and then PyAutoGui to click at the desired area of screen. This 'allow' popup appears always in the same place, you can just click it... (but it's definitely a dirty hack with many problems) – STerliakov Apr 02 '21 at 18:06

1 Answers1

1

I believe this is a duplicate question:

How to deal with certificates using Selenium?

Per that answer, for Chrome:

For Chrome, you need to add --ignore-certificate-errors ChromeOptions() argument:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument('ignore-certificate-errors')

driver = webdriver.Chrome(chrome_options=options)
driver.get('https://cacert.org/')

driver.close()