I am trying to run the following code, but I encounter a Driver's SessionNotCreatedException error.
Could you please have any ideaas how to specify a ChromeProfile when using Chrome For Testing?
Error Code: Exception has occurred: SessionNotCreatedException Message: session not created: Chrome failed to start: exited normally. (session not created: DevToolsActivePort file doesn't exist) (The process started from chrome location C:\Windows\System32\chrome\win64-120.0.6099.109\chrome-win64\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
My Code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
# set specify my profile
chrome_options = Options()
chrome_options.add_argument(r'user-data-dir=C:\Users\****\AppData\Local\Google\Chrome\User Data')
chrome_options.add_argument('profile-directory=Profile 05')
# set Chrome folder
chrome_options.binary_location = r'C:\Windows\System32\chrome\win64-120.0.6099.109\chrome-win64\chrome.exe'
# set ChromeDriver folder
driver_path = r'C:\Windows\System32\chromedriver\win64-120.0.6099.109\chromedriver-win64\chromedriver.exe'
# launch browser
driver = webdriver.Chrome(executable_path = driver_path, options=chrome_options)
# Open google
driver.get('https://www.google.co.jp/')
# waiting
time.sleep(3)
# close browser
driver.close()
I checked them below.. but seems not solved
You can find the user data dir of Chrome for Testing for macOS and Linux here.
For Windows there's an extra layer of indirection, c.f. here.
Basically, change
chrome_options.add_argument(r'user-data-dir=C:\Users\****\AppData\Local\Google\Chrome\User Data')
to
chrome_options.add_argument(r'user-data-dir=C:\Users\****\AppData\Local\Google\Chrome for Testing\User Data')