简体   繁体   中英

How to create Python Selenium Chrome webdriver remote with Current user data?

  1. How I create LOCAL Chrome Webdriver WITH Current user data

     chromedriver = "/Users....../chromedriver" os.environ["webdriver.chrome.driver"] = chromedriver options = webdriver.ChromeOptions() options.add_argument(r"user-data-dir=/Users..../Google/Chrome") webdriver.Chrome(executable_path=chromedriver, chrome_options=options)
  2. How I create REMOTE Chrome webdriver with clear - new user data

    webdriver.Remote(command_executor="http://192.168.1.30:4441/wd/hub", desired_capabilities=DesiredCapabilities.CHROME)

Now, How create Remote Chrome webdriver with current user data?

Try this:

os.environ["webdriver.chrome.driver"] = chromedriver
options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=/Users..../Google/Chrome")
webdriver.Remote("http://192.168.1.30:4441/wd/hub",
        options.to_capabilities())

And if you have your chromedriver.exe on the PATH then you should not need this part:

chromedriver = "/Users....../chromedriver"

Not sure if that works for you, but here is an example that let me start remote chrome webdriver with desired chromeOption for language:

options = webdriver.ChromeOptions()
options.add_argument("--lang=de")
chrome_remote = webdriver.Remote('http://hostname:4444/wd/hub', options.to_capabilities())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM