I'm trying to use my chrome profile with webdriver but it says its already attached

599 Views Asked by At

You can see the code which I am using below to use another profile with webdriver. I'm needing to know how this is done since I want to be able to load my current chrome profile in to webdriver

options.AddArguments(String.Format(
   "--user-data-dir=\"{0}\"", @"C:\Users\zacha\source\repos\Trial Bot - Test\Trial Bot - Test\bin\Debug\User Data"));
         

            
            driver = new ChromeDriver(@"C:\Users\zacha\source\repos\Trial Bot - Test\Trial Bot - Test\",options);

Error when ran:

OpenQA.Selenium.WebDriverException: 'unknown error: Could not remove old devtools port file. Perhaps the given user-data-dir at "C:\Users\zacha\source\repos\Trial Bot - Test\Trial Bot - Test\bin\Debug\User Data" is still attached to a running Chrome or 
1

There are 1 best solutions below

0
On

This error message...

OpenQA.Selenium.WebDriverException: 'unknown error: Could not remove old devtools port file. Perhaps the given user-data-dir at "C:\Users\zacha\source\repos\Trial Bot - Test\Trial Bot - Test\bin\Debug\User Data" is still attached to a running Chrome

...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser using the Chrome Profile through the argument --user-data-dir as the desired Chrome Profile is still in usage by a running browsing instance.


Possibly the Chrome Profile which you are trying to access through Selenium driven ChromeDriver initiated Google Chrome Browsing Context is the same profile you are accessing manually for your other/debugging tasks i.e. the Trial Bot - Test profile. So, the Chrome Profile remains locked and not accessable by ChromeDriver. Hence you see the error.

As a solution try to use different Chrome Profiles for different tasks.