Search
  • Seema Nair

Creating profiles in Google Chrome


In any web application , there are several features where we need to test without clearing the browser cache. By default, when we use chrome driver in test automation, it creates a profile in the temp location and launches a clean browser state.

If we want to retain the browser state , then we need to create a custom chrome profile for our scripts. To do this, follow the below steps

Create Chrome Profile :

  • Open Chrome Browser and click on Setting option.

  • Scroll down the page and click on Add person option.Give a name and click on Add button.

  • After creation this profile we can find that a folder created under "Documents and Settings\Administrator\Local Settings\Application Data\Google\Chrome\User Data"

  • Now in your Selenium script, add the following lines of code so that the script launches the profile created by you with cache enabled.

  • DesiredCapabilities cap = new DesiredCapabilities();

  • ChromeOptions options = new ChromeOptions();

  • options.addArguments("--disable-extensions");

  • System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");

  • options.addArguments("user-data-dir=C:/Users/Administrator/AppData/Local/Google/Chrome/User Data");

  • options.addArguments("--start-maximized");

  • cap.setCapability(ChromeOptions.CAPABILITY, options);

  • cap.setCapability("applicationCacheEnabled", "true");

  • cap.setBrowserName("Chrome");

#webdriver #chromedriver #Selenium #WebAutomation #CacheEnabled #Chromeprofile

30 views0 comments

Recent Posts

See All