-
Notifications
You must be signed in to change notification settings - Fork 1.4k
-
import time import logging from selenium.webdriver import ChromeOptions, Chrome from seleniumbase import Driver def get_driver(use_base=False): chrome_options = ChromeOptions() prefs = {"download.default_directory": "downloads", "plugins.plugins_list": [{"enabled": False, "name": "Chrome Pdf Viewer"}], "plugins.always_open_pdf_externally": True, "profile.default_content_setting_values.automatic_downloads": 1, } chrome_options.add_argument('window-size=1200x600') chrome_options.add_argument("--no-sandbox") chrome_options.add_argument("--disable-setuid-sandbox") chrome_options.add_argument("--disable-dev-shm-usage") chrome_options.add_argument("--ignore-ssl-errors=yes") chrome_options.add_argument("--ignore-certificate-errors") chrome_options.add_experimental_option("prefs", prefs) chrome_options.accept_insecure_certs = True if use_base: logging.info("Instantiating Chrome with SeleniumBase...") return Driver(browser="chrome", undetected=True, options=chrome_options) else: logging.info("Instantiating Chrome with standard Selenium WebDriver...") return Chrome(options=chrome_options) driver = get_driver() driver.get("https://www.google.co.in/") time.sleep(10) driver.quit()
I'm trying to get undetected driver with my custom options, is there any method which can get this done?
I saw the discussions which says both not possible. is any new method there OR in Driver
can i add prefs, --ignore-ssl-errors=yes & accept_insecure_certs
?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 7 replies
-
Duplicate of #1677 (comment).
The important args you mentioned are already being set. Eg:
Beta Was this translation helpful? Give feedback.
All reactions
-
👀 1
-
with
undetected=True
i want to set these:chrome_options.add_experimental_option("prefs", prefs)
Brother i want to apply these experiment flags
prefs = {"download.default_directory": "downloads", "plugins.plugins_list": [{"enabled": False, "name": "Chrome Pdf Viewer"}], "plugins.always_open_pdf_externally": True, "profile.default_content_setting_values.automatic_downloads": 1, }
Here i can seeautomatic_downloads
present in browser_launcher.py
& always_open_pdf_externally
i can use by the flag external_pdf
.
"download.default_directory": my_external_dir,
But how can i pass download directory path to download.default_directory?
"plugins.plugins_list": [{"enabled": False, "name": "Chrome Pdf Viewer"}],
And how to disable the Chrome Pdf Viewer plugin, i searched plugins_list
found nothing
Beta Was this translation helpful? Give feedback.
All reactions
-
The external_pdf=True
option lets you download PDFs instead of displaying them.
The download directory cannot be changed. (It is the ./downloaded_files/
folder.)
After files are downloaded, you can move them using Python.
Beta Was this translation helpful? Give feedback.
All reactions
-
❤️ 1
-
Got it, Thanks.
Is there any plan for making the download directory as argument instead of hardcoded path?
It would be helpful for downloading simultaneously from multiple instances in different directory.
Beta Was this translation helpful? Give feedback.
All reactions
-
It's hard-coded for a reason: All contents of the ./downloaded_files
folder are cleared out at the beginning of each pytest
run. For safety, we won't let people set that folder to something else. People can use Python to copy files from that folder as needed.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Understandable. i'll have to fork & use for my own purpose, anyways thank you.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1