Para Firefox, debe configurar la accept_untrusted_certs
FirefoxProfile()
opción para True
:
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()
Para Chrome, debe agregar un argumento:--ignore-certificate-errors
ChromeOptions()
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()
Para Internet Explorer, debe configurar la acceptSslCerts
capacidad deseada:
from selenium import webdriver
capabilities = webdriver.DesiredCapabilities().INTERNETEXPLORER
capabilities['acceptSslCerts'] = True
driver = webdriver.Ie(capabilities=capabilities)
driver.get('https://cacert.org/')
driver.close()
En realidad, de acuerdo con la Desired Capabilities
documentación , la acceptSslCerts
capacidad de configuración True
debería funcionar para todos los navegadores, ya que es una capacidad genérica de lectura / escritura:
acceptSslCerts
booleano
Si la sesión debe aceptar todos los certificados SSL de forma predeterminada.
Demostración funcional para Firefox:
>>> from selenium import webdriver
Ajuste acceptSslCerts
a False
:
>>> capabilities = webdriver.DesiredCapabilities().FIREFOX
>>> capabilities['acceptSslCerts'] = False
>>> driver = webdriver.Firefox(capabilities=capabilities)
>>> driver.get('https://cacert.org/')
>>> print(driver.title)
Untrusted Connection
>>> driver.close()
Ajuste acceptSslCerts
a True
:
>>> capabilities = webdriver.DesiredCapabilities().FIREFOX
>>> capabilities['acceptSslCerts'] = True
>>> driver = webdriver.Firefox(capabilities=capabilities)
>>> driver.get('https://cacert.org/')
>>> print(driver.title)
Welcome to CAcert.org
>>> driver.close()