Sunday, August 25, 2019

How to open exisiting chrome web browser ( with original History, Cache and Cookies ) using selenium C#

As we all know, when we say  driver = new ChromeDriver()
it will open a new chrome window with no Cache ,History or Cookies.

But in 1 day I had a requirement to open the existing google chrome web browser and continue my selenium tests on that browser.
So this is how I did it.


Go to chrome://version/ and locate the Profile Path.
Copy entire Default folder and copy it to some where else.

e.g- C:/Driver/test

then set your code like below.

ChromeOptions options = new ChromeOptions();
options.AddArguments(@"user-data-dir=C:\Driver\test");

driver = new ChromeDriver(options);