Travis Couture
Travis Couture

Reputation: 29

Using Selenium to By-pass SSL Certification In Internet Explorer (Python)

I have done some searching on this issue and have not found any working solutions. Essentially, I am trying to write a script that utilizes Selenium to open a particular site and enter user login information. However, Internet Explorer returns a certificate warning as shown:

Here is the code I am using

class PipelinePilotControl:
    user_id = str(input("Please enter your username.\n"))
    user_password = getpass.getpass(prompt="Please enter your password.\n")

    def pipelinepilot_login(self):
        ie_browser_driver = webdriver.Ie()
        ie_browser_driver.get("url to be accessed")
        user_login = ie_browser_driver.find_element_by_id("txtUsername")
        password_login = ie_browser_driver.find_element_by_id("txtPassword")
        login_button = ie_browser_driver.find_element_by_id("btnLogin")
        user_login.send_keys(self.user_id)
        password_login.send_keys(self.user_password)
        login_button.send_keys(Keys.ENTER)

I have tried using the html and the get_element_by_id functionality in selenium as well as capability controls but nothing has worked. Any suggestions?

Thanks, Travis

Upvotes: 0

Views: 942

Answers (1)

themoah
themoah

Reputation: 187

SSL error page in IE isn't Shadow DOM, you can navigate on the page and just click on "Continue". Try 'find_element' :

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

caps = webdriver.DesiredCapabilities().INTERNETEXPLORER
caps['acceptSslCerts'] = True

driver = webdriver.Ie(capabilities=caps)
driver.get('https://yourwebsite.com/')

overrideLink = driver.find_element_by_id('overridelink')
overrideLink.click()

Upvotes: 1

Related Questions