i recently ran into the problem, that all my python scripts which utilize the selenium module are broken apparently due to a google chrome update. It seems like selenium/google chrome always asks to select a user profile no matter what options are given inside the python script e.g. “user-data-dir” has no effect at all. This occurs even in headless mode. The original script was able to download a pdf in the background without the “user-data-dir” option.
Has anyone run into the same issue and found a solution to it?
Below an example code which worked fine before.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless')
#options.add_argument(r"--user-data-dir=C:UsersxxxAppDataLocalGoogleChromeUser DataProfile 1") # this option does not make any difference
options.add_argument('log-level=3')
options.add_experimental_option("prefs", {
"download.default_directory": directory,
"download.prompt_for_download": False,
"download.directory_upgrade": True,
"plugins.always_open_pdf_externally": True,
})
driver = webdriver.Chrome(options=options)
driver.get("http://www.google.com") #original code used a different website
Using selenium in python without having to select a user profile.
0
This is not an actual answer to selenium, but for now my solution is to abandon selenium and instead use playwright which can be used just the same way i need.