ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.72k stars 1.14k forks source link

experimental_option prefs not working #260

Open QuentiumYT opened 3 years ago

QuentiumYT commented 3 years ago

Hello, using Undetected Chromedriver V2, the 'prefs' experimental option isn't valid.

I tried the following code:

chrome_options = uc.ChromeOptions()

prefs = {
    "download.default_directory": os.getcwd()
}

chrome_options.add_experimental_option("prefs", prefs)

but this is also for all other prefs keys, not only download.default_directory.

The error

selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: cannot parse capability: goog:chromeOptions
from invalid argument: unrecognized chrome option: prefs

Thanks for any fix or solution!

QuentiumYT commented 3 years ago

Also refers to #194, #213 and #211

ultrafunkamsterdam commented 3 years ago

A damn, that's right. I still need to push rewritten options , but no pc at hand now

janjelonek commented 3 years ago

How is it going? Seems that problem still occurs :(

Bl3sk commented 3 years ago

Any news? :((

QuentiumYT commented 3 years ago

Well, I found a way using a browser command:

browser = uc.Chrome()

# Defines autodownload and download PATH
params = {
    "behavior": "allow",
    "downloadPath": os.getcwd()
}
browser.execute_cdp_cmd("Page.setDownloadBehavior", params)

I hope it will help πŸ˜„ @janjelonek @Bl3sk

Bl3sk commented 3 years ago

Well, I found a way using a browser command:

browser = uc.Chrome()

# Defines autodownload and download PATH
params = {
    "behavior": "allow",
    "downloadPath": os.getcwd()
}
browser.execute_cdp_cmd("Page.setDownloadBehavior", params)

I hope it will help πŸ˜„ @janjelonek @Bl3sk

Thanks for trying to helpβ™₯, but I need to fix error with prefs, because I need to disable popups. :(

QuentiumYT commented 3 years ago

If you want to disable popups, you can do

chrome_options.add_argument("--disable-popup-blocking")

It should work @Bl3sk, else, we need a little fix for prefs :)

Bl3sk commented 3 years ago

It didnt crash, but doesnt work. :( Popups still appears.

Bl3sk commented 3 years ago

options = uc.ChromeOptions() options.add_argument("--disable-popup-blocking") driver = uc.Chrome(options=options) driver.maximize_window() driver.get("https://www.seznam.cz/")

frederikme commented 3 years ago

Any update on this? I need to use experimental_option to automatically accept a location requested popup.

QuentiumYT commented 3 years ago

@frederikme As a temporary fix, you should use cdp commands

browser.execute_cdp_cmd(
    "Browser.grantPermissions",
    {
        "origin": "https://yourwebsite/",
        "permissions": ["geolocation"]
    },
)

It should be working, but it's per website only

frederikme commented 3 years ago

@QuentiumYT Works like a charm! Thanks! :-)

ScamCast commented 2 years ago

Prefs still not working

ShayBox commented 2 years ago

I don't know how or why v2 came to be without support for full chrome_options/ChromeOptions, but until it gets it, many features such as image disabling, proxy support, detatch, etc will not work or not work without workarounds that don't work as-well.

Mind you this also breaks compatibility with seleniumwire_options, the main project UC is used with.

I suggest anyone that needs this go back to using v1 as I have. import undetected_chromedriver._compat as uc

Dzeri96 commented 2 years ago

Hope this issue wasn't abandoned...

sebdelsol commented 2 years ago

Please check this potential solution

maneendra-zen3 commented 1 year ago

Well, I found a way using a browser command:

browser = uc.Chrome()

# Defines autodownload and download PATH
params = {
    "behavior": "allow",
    "downloadPath": os.getcwd()
}
browser.execute_cdp_cmd("Page.setDownloadBehavior", params)

I hope it will help πŸ˜„ @janjelonek @Bl3sk

This is good, But I need to set the download location in uc.Chrome() as I am deploying the application on AWS Lambda. Unfortunately, If I do not do that. the uc.Chrome is trying to write to a read-only file on AWS and I am getting this error. I basically need to write to /tmp on OS level. Is there any way to do this?

"errorMessage": "[Errno 30] Read-only file system: '/home/sbx_user1051'",
  "errorType": "OSError",