Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Can i use ChromeOptions with undected mode? #3321

Jisan00b started this conversation in General
Discussion options

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 ?

You must be logged in to vote

Replies: 1 comment 7 replies

Comment options

Duplicate of #1677 (comment).

The important args you mentioned are already being set. Eg:

chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-setuid-sandbox")
chrome_options.add_argument("--ignore-certificate-errors")
You must be logged in to vote
7 replies
Comment options

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

Comment options

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.

Comment options

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.

Comment options

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.

Comment options

Understandable. i'll have to fork & use for my own purpose, anyways thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /