I am using Selenium WebDriver for Chrome to open two instances of Google Chrome with two different Profiles (Profile 1 and Profile 2) simultaneously. The first instance with Profile 1 opens successfully. But when I try to open the second instance of Chrome with Profile 2, I get an error.
Here's my Python code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
#Profile Directory for Google Chrome
dataDir = "--user-data-dir=C:\\Users\\Myname\\AppData\\Local\\Google\\Chrome\\User Data"
#Setting the Chrome options for Profile 1
chrome_options1 = Options()
chrome_options1.add_argument(dataDir)
chrome_options1.add_argument("--profile-directory=Profile 1")
driver1 = webdriver.Chrome(chrome_options=chrome_options1)
#This opens www.google.com sucessfully
driver1.get('https://www.google.com')
#Setting the Chrome options for Profile 2
chrome_options2 = Options()
chrome_options2.add_argument(dataDir)
chrome_options2.add_argument("--profile-directory=Profile 2")
#The below line throws an error (Cannot move the Shared Cache)
driver2 = webdriver.Chrome(chrome_options=chrome_options2)
#This line is not reached as there is error in creating driver2 itself
driver2.get('https://www.google.com')
Here's the error I'm getting:
[1076:11808:0716/182552:ERROR:cache_util_win.cc(20)] Unable to move the cache: 0
[1076:11808:0716/182552:ERROR:cache_util.cc(134)] Unable to move cache folder C:
\Users\Myname\AppData\Local\Google\Chrome\User Data\ShaderCache\GPUCache to C:\U
sers\Myname\AppData\Local\Google\Chrome\User Data\ShaderCache\old_GPUCache_000
[1076:11808:0716/182552:ERROR:cache_creator.cc(129)] Unable to create cache
[1076:11808:0716/182552:ERROR:shader_disk_cache.cc(589)] Shader Cache Creation failed: -2
I think the error is because the first instance of chrome has locked the shared cache folder (for writing). Therefore, When the second instance tries to open the same shared folder it throws an error.
Is there any workaround for this?
My goal is to open two Chrome instances with two different Profiles simultaneously.
Any help is Appreciated.