简体   繁体   中英

How can I share my current Chrome profile with Selenium?

I'd like to use Selenium alongside my current Chrome profile, which may or may not be in use. I'd like to be able to launch some Selenium automation that is aware of (for example) any currently set cookies from my current Chrome session. I'd also like my Selenium automation to be able to change cookies that will still persist in my local profile.

Example:

  1. I'd like to be able to manually log into a website (without Selenium)
  2. I'd like to then launch some Selenium automation that assumes I'm already logged in (which I would be)
  3. I'd like to then make some type of change through the Selenium automation
  4. I'd like to close out the Selenium automation and see the changes that were made reflected in my original, manually-initiated, session

I know this can technically be achieved by setting user-data-dir in ChromeOptions, however that results in the following errors:

[20644:39092:1124/205239:ERROR:cache_util_win.cc(20)] Unable to move the cache: 0
[20644:39092:1124/205239:ERROR:cache_util.cc(134)] Unable to move cache folder C:\Users\****\AppData\Local\Google\Chrome\User Data\Default\ShaderCache\GPUCache to C:\Users\****\AppData\Local\Google\Chrome\User Data\Default\ShaderCache\old_GPUCache_000
[20644:39092:1124/205239:ERROR:cache_creator.cc(134)] Unable to create cache
[20644:39092:1124/205239:ERROR:shader_disk_cache.cc(585)] Shader Cache Creation failed: -2

Have you reviewed the permissions of the directories listed in the error message? They should share the same group and have write permissions.

This should solve the messages, but your implementation looks to be correct.

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