Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98757

How to upload a ssl certificate into google chrome webdriver in selenium python

$
0
0

I need to use selenium python with an uploaded personal security certificate every time my service launch a new process, and for some reason is not possible to click at import in the Google Chrome settings.

I try to use XPATH, ID and other By options, and no way to work. If anyone has experience with this type of problem, would appreciate the help.

The error that mostly happen is

File "", line 2, in element = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="import"]')))File "/home/pc/.local/lib/python3.10/site-packages/selenium/webdriver/support/wait.py", line 105, in untilraise TimeoutException(message, screen, stacktrace)selenium.common.exceptions.TimeoutException: Message:

Any help will be highly appreciated!

My code

from selenium.webdriver.chrome.service import Service as ChromeServicefrom webdriver_manager.chrome import ChromeDriverManagerfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.common.action_chains import ActionChainsfrom selenium.webdriver.common.by import Byfrom selenium import webdriverimport osdef create_webdriver_chrome(download_dest):    options = webdriver.ChromeOptions()    options.add_experimental_option('excludeSwitches', ['enable-logging'])    options.add_experimental_option("excludeSwitches", ["enable-automation"])    options.add_experimental_option('useAutomationExtension', False)    prefs = {"download.default_directory": download_dest,"download.directory_upgrade": True,"download.prompt_for_download": False,"disable-popup-blocking": False,"profile.default_content_settings.popups": 0    }    options.add_experimental_option("prefs", prefs)    options.add_argument('--disable-blink-features=AutomationControlled')    options.add_argument("--lang=pt-BR")    chrome_service_obj = ChromeService(executable_path=ChromeDriverManager().install())    driver = webdriver.Chrome(service=chrome_service_obj, options=options)    return driverdowndir_dest = os.path.join(os.getcwd(), 'downdir')driver = create_webdriver_chrome(downdir_dest)driver.get("chrome://settings/certificates")wait = WebDriverWait(driver, 2)element = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="import"]')))driver.execute_script("arguments[0].scrollIntoView();", element)ActionChains(driver).move_to_element(element).click().perform()

The pages it need to open are:

 [![The Google Chrome Settings Page for certificates ][1]][1] [![and them upload the certificate by clicking on "Import", and doing all the following password send and so on.][1]][1]

Viewing all articles
Browse latest Browse all 98757

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>