Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable the "Insecure Connection" while opening up a private browser from python selenium script?

While running my python selenium script for firefox browser; I encountered an issue saying

Your connection is not secure

It is not allowing me to Add exception and blocked

Confirm Security Exception

as well (even with preferences manually). hence i am trying to add profiles like "webdriver_accept_untrusted_certs", "webdriver_accept_untrusted_certs" but nothing is helping me out. Not sure how to tackle this...

I need some help here

Currently using the following... Python 3.4.4 selenium==3.4.1 linux 32 bit Firefox 60.6.1esr (32-bit) Everything seems to be compatible, so no issue here.

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import     DesiredCapabilities

cap = DesiredCapabilities().FIREFOX
profile = webdriver.FirefoxProfile()
profile.set_preference("webdriver_assume_untrusted_issuer", False)
profile.update_preferences()
browser = webdriver.Firefox(capabilities=cap,firefox_profile=profile)
browser.get('my url')

and

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import     DesiredCapabilities

cap = DesiredCapabilities().FIREFOX
profile = webdriver.FirefoxProfile()
profile.set_preference("webdriver_accept_untrusted_certs", True)
browser = webdriver.Firefox(capabilities=cap,firefox_profile=profile)
browser.get('my url')

I want to get rid of the "Your Connection is not secure"

like image 621
Bharath Kashyap Avatar asked Oct 20 '25 15:10

Bharath Kashyap


1 Answers

For FireFox you can use:

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

desired_caps = DesiredCapabilities.FIREFOX.copy()
desired_caps.update({'acceptInsecureCerts': True, 'acceptSslCerts': True})
driver = webdriver.Firefox(capabilities=self.desired_caps)

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)
like image 120
Nic Laforge Avatar answered Oct 23 '25 06:10

Nic Laforge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!