1

Hey Everyone. This little script is driving me crazy so I am calling for backup. When I run the script below it gives me

TypeError: init() got multiple values for argument 'command_executor'

It would be nice if anyone could give me a hand.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

# The main process calls this function to create the driver instance.
def createDriverInstance():
    options = Options()
    options.add_argument('--disable-infobars')
    driver = webdriver.Chrome(r'mypath',chrome_options=options)
    return driver

# Called by the second process only.
def secondProcess(executor_url, session_id):
    options = Options()
    options.add_argument("--disable-infobars")
    options.add_argument("--enable-file-cookies")
    capabilities = options.to_capabilities()
    same_driver = webdriver.Remote(r'mypath',command_executor=executor_url,desired_capabilities=capabilities)
    same_driver.close()
    same_driver.session_id = session_id
    same_driver.get("https://www.wikipedia.org")
    time.sleep(4)
    same_driver.quit()

if __name__ == '__main__':
    driver = createDriverInstance()
    driver.get("https://google.com")
    time.sleep(2)

    # Pass the driver session and command_executor to the second process.
    secondProcess(driver.command_executor._url,driver.session_id)

1 Answer 1

1

webdriver.Remote doesn't have an argument for the path to the chromedriver file, so you don't have to use it.

So just change this line from this:

same_driver = webdriver.Remote(r'mypath',command_executor=executor_url,desired_capabilities=capabilities)

to this:

same_driver = webdriver.Remote(command_executor=executor_url,desired_capabilities=capabilities)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.