Application sets the cookie after doing a particular action in the browser. Am Trying to quit the browser and relaunch the browser session again but not able to find the particular cookie again in the browser window. Am Using the Chrome browser. I have tried to manually relaunch the browser again and search for the cookie and am able to find it
Can some one help on this. Not sure if my code is clearing out the Cookie
Code used
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("ignore-certificate-errors");
Object proxy = getCorrectProxy();
chromeOptions.setCapability(CapabilityType.PROXY, proxy);
chromeOptions.setCapability("acceptInsecureCerts", true);
chromeOptions.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
chromeOptions.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, true);
System.setProperty("webdriver.chrome.driver", GlobalSettings.CHROME_DRIVER_PATH);
driver = new ChromeDriver(chromeOptions);
Tried this code below without Chrome options as well but still dont see the Cookie
System.setProperty("webdriver.chrome.driver", GlobalSettings.CHROME_DRIVER_PATH);
driver = new ChromeDriver();
By Default Selenium Webdriver launches the chrome browser as Anonymous mode and doesn't retain the cookies. So when we use the default chrome profiles, Persistent Cookies are retained and code is given below . This has be tested and working fine
Note: Just added code for only the piece of code for Chromeoption that is used to use the default chrome profile. other necessary Chrome options according to requirements
ChromeOptions chromeOptions = new ChromeOptions();
strUserProfile=System.getenv("USERPROFILE");
strUserProfile=strUserProfile+"\\AppData\\Local\\Google\\Chrome\\User Data";
chromeOptions.addArguments("user-data-dir="+strUserProfile);
driver = new ChromeDriver(chromeOptions);