Chrome用Selenium WebDriverを使用して、2つの異なるプロファイル(プロファイル1とプロファイル2)プロファイル1の最初のインスタンスが正常に開きます。しかし、プロファイル2でChromeの2番目のインスタンスを開こうとすると、エラーが発生します。PythonでChrome用Selenium Webドライバを使用して2つのGoogle Chromeインスタンスを開くことはできません
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')
ここで私が取得していますエラーがあります:
は、ここに私のPythonコードです
[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
私はクロームの最初のインスタンスは、(のための共有キャッシュフォルダをロックしているため、エラーがあると思います書き込み)。したがって、2番目のインスタンスが同じ共有フォルダを開こうとすると、エラーがスローされます。
これに対応する方法はありますか?
私の目標は、2つの異なるプロファイルで同時に2つのChromeインスタンスを開くことです。
ヘルプは評価されています。
ありがとうございました!ここに私がしたことがあります。あなたが言及したように、私はプロファイルフォルダ(Profile1とProfile2)を分離し、それらを異なる親フォルダに配置しました。これらのプロファイルパスを持つ2つのChromeインスタンスを開くためにPythonスクリプトを実行すると、自動的に共有フォルダ(ShaderCache)が作成されました。 –