How to disable SSL check in Python Selenium to access microphone?

3.7k Views Asked by At

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?

1

There are 1 best solutions below

0
CosmicHedonicTreadmill On

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