selenium-wire icon indicating copy to clipboard operation
selenium-wire copied to clipboard

TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'

Open pedrofnts opened this issue 2 years ago • 6 comments

Hello, I'm trying to use webdriver.Remote with selenium-wire to create an instance of browserless, but I keep getting this error

TypeError: WebDriver.init() got an unexpected keyword argument 'desired_capabilities'

Here's my code:

def create_chrome_driver():
    options = webdriver.ChromeOptions()
    options.add_argument("--disable-dev-shm-usage")
    options.add_argument("--no-sandbox")
    options.add_argument("--start-maximized")
    options.add_argument("--window-size=1920x1080")
    options.set_capability('browserless:stealth', True)
    proxies = chrome_proxy(proxy_username, proxy_password, proxy_endpoint)

    driver = webdriver.Remote(
        command_executor='https://**my api**@chrome.browserless.io/webdriver',
        options=options, seleniumwire_options=proxies)

    return driver

I'm not passing desidered_capabilities. Why this is happening?

pedrofnts avatar Jul 20 '23 19:07 pedrofnts

The linked PR will not fix this issue in its current state. More work would need to be done to make a fix for this possible (if desired by wkeeling).

jdholtz avatar Jul 31 '23 02:07 jdholtz

Bump.

I'm running into the same issue, a fix would be greatly appreciated.

(Just to clarify: I'm also trying to use webdriver.Remote, and getting the same error message regarding desidered_capabilities even though I haven't passed it as an argument.)

hrf2 avatar Sep 15 '23 07:09 hrf2

Another bump

Error:

TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'

Code (no clue if it would work anyway, working on it):

from seleniumwire import webdriver
options = {
    'proxy': {
        'http': the_proxy_addr, 
        'https': the_proxy_addr,
        # 'no_proxy': 'localhost,127.0.0.1', # excludes
        'custom_authorization': f'{username} {password}' 
    }
}
driver = webdriver.Remote(
    command_executor= "http://172.17.0.2:4444/wd/hub", 
    seleniumwire_options=options
)

@pedrofnts the issue is happening because desired_capabilities was deprecated as of 4.10.0 and I'm assuming seleniumwire uses it under the hood in some way.

You can downgrade which I might try but I'm not a huge fan of that solution.

surfingdoggo avatar Sep 26 '23 16:09 surfingdoggo

Update: I tried it on 4.9.1 and it still didn't work :(

If I figure anything else out I'll share with the class

surfingdoggo avatar Sep 26 '23 16:09 surfingdoggo

@surfingdoggo test this:

For old selenium (< 4.10): dc = DesiredCapabilities.CHROME.copy() dc["goog:loggingPrefs"] = {"browser":"INFO"}

For "new" selenium (>=4.10), you need to place it using options.set_capability: options = webdriver.ChromeOptions() options.set_capability("goog:loggingPrefs", {browser: "INFO"})

https://github.com/wkeeling/selenium-wire/issues/687#issuecomment-1732311567

pedrofnts avatar Sep 27 '23 11:09 pedrofnts

@surfingdoggo test this:

For old selenium (< 4.10): dc = DesiredCapabilities.CHROME.copy() dc["goog:loggingPrefs"] = {"browser":"INFO"} For "new" selenium (>=4.10), you need to place it using options.set_capability: options = webdriver.ChromeOptions() options.set_capability("goog:loggingPrefs", {browser: "INFO"})

https://github.com/wkeeling/selenium-wire/issues/687#issuecomment-1732311567

This does not work, I'm afraid. The issue persists.

alexppg avatar Oct 25 '23 18:10 alexppg