chromedriver C# using User Profile for cache testing

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

chromedriver C# using User Profile for cache testing

JT-3
I am trying to enable caching for chromedriver by setting up a user profile for the chrome driver.  Here's my C# code:

ChromeOptions options = new ChromeOptions();
var username = System.Environment.GetEnvironmentVariable("USERNAME");
var userProfile = "C:/Users/" + username + "/AppData/Local/Google/Chrome/User Data/Profile 2"; 
options.AddArguments("user-data-dir=" + userProfile);

var chromeDriverDirectory = "..\..\seleniumWebdrivers\chromeDriver\chromedriver2.42-win32";
var driver = new ChromeDriver(@chromeDriverDirectory, options, TimeSpan.FromSeconds(60));


When the chrome browser opens, I receive a popup "Restore pages? Chrome didn't shut down correctly" message.

How do I disable getting this message?



 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/19e04c23-9339-412d-b98e-b6e588e86d05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: chromedriver C# using User Profile for cache testing

skonthebass
Have you tried turning off popups?

Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings.popups", 0);
options.setExperimentalOption("prefs", prefs);

On Tuesday, October 30, 2018 at 10:31:14 PM UTC-4, JT wrote:
I am trying to enable caching for chromedriver by setting up a user profile for the chrome driver.  Here's my C# code:

ChromeOptions options = new ChromeOptions();
var username = System.Environment.GetEnvironmentVariable("USERNAME");
var userProfile = "C:/Users/" + username + "/AppData/Local/Google/Chrome/User Data/Profile 2"; 
options.AddArguments("user-data-dir=" + userProfile);

var chromeDriverDirectory = "..\..\seleniumWebdrivers\chromeDriver\chromedriver2.42-win32";
var driver = new ChromeDriver(@chromeDriverDirectory, options, TimeSpan.FromSeconds(60));


When the chrome browser opens, I receive a popup "Restore pages? Chrome didn't shut down correctly" message.

How do I disable getting this message?



 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/0016886a-9f6a-418f-a7e1-e53c4083e728%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: chromedriver C# using User Profile for cache testing

JT-3
In reply to this post by JT-3
Turns out I needed to AddArgument --profile-directory

so the code is:

ChromeOptions options = new ChromeOptions();
var username = System.Environment.GetEnvironmentVariable("USERNAME");
var userProfile = "C:/Users/" + username + "/AppData/Local/Google/Chrome/User Data"; 
options.AddArguments("user-data-dir=" + userProfile);
options.AddArgument("--profile-directory="  + "Profile 2");

var chromeDriverDirectory = "..\..\seleniumWebdrivers\chromeDriver\chromedriver2.42-win32";
var driver = new ChromeDriver(@chromeDriverDirectory, options, TimeSpan.FromSeconds(60));




On Tuesday, October 30, 2018 at 10:31:14 PM UTC-4, JT wrote:
I am trying to enable caching for chromedriver by setting up a user profile for the chrome driver.  Here's my C# code:

ChromeOptions options = new ChromeOptions();
var username = System.Environment.GetEnvironmentVariable("USERNAME");
var userProfile = "C:/Users/" + username + "/AppData/Local/Google/Chrome/User Data/Profile 2"; 
options.AddArguments("user-data-dir=" + userProfile);

var chromeDriverDirectory = "..\..\seleniumWebdrivers\chromeDriver\chromedriver2.42-win32";
var driver = new ChromeDriver(@chromeDriverDirectory, options, TimeSpan.FromSeconds(60));


When the chrome browser opens, I receive a popup "Restore pages? Chrome didn't shut down correctly" message.

How do I disable getting this message?



 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/5370e5f3-8fd9-4d7c-994b-d311f6d16e4a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.