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:
- I’m using an already open window.
- 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:
JavaScript
x
7
1
from selenium import webdriver
2
3
options = webdriver.ChromeOptions()
4
options.add_argument('--ignore-ssl-errors=yes')
5
options.add_argument('--ignore-certificate-errors')
6
driver = webdriver.Chrome(options=options)
7
If not work then this:
JavaScript
1
9
1
from selenium import webdriver
2
from selenium.webdriver import DesiredCapabilities
3
4
options = webdriver.ChromeOptions()
5
options.add_argument('--allow-insecure-localhost') # differ on driver version. can ignore.
6
caps = options.to_capabilities()
7
caps["acceptInsecureCerts"] = True
8
driver = webdriver.Chrome(desired_capabilities=caps)
9
For firefox:
JavaScript
1
10
10
1
from selenium import webdriver
2
3
profile = webdriver.FirefoxProfile()
4
profile.accept_untrusted_certs = True
5
6
driver = webdriver.Firefox(firefox_profile=profile)
7
driver.get('https://cacert.org/')
8
9
driver.close()
10
If not work then this:
JavaScript
1
6
1
capabilities = webdriver.DesiredCapabilities().FIREFOX
2
capabilities['acceptSslCerts'] = True
3
driver = webdriver.Firefox(capabilities=capabilities)
4
driver.get('https://cacert.org/')
5
driver.close()
6
Above all worked for me!