Tests from the custom Chrome profile

Google Chrome is always the preferable browser on which to run tests. The Firefox and Chrome browsers work with binary. However, Internet Explorer doesn't need a profile to be set up to run tests because they run on the server user. In Chrome, the user data directory contains all the data of the given user, which includes history, bookmarks, and cookies. Add the following snippet to run tests from a new profile:

System.setProperty ("webdriver.chrome.driver","C:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data");
options.addArguments("--start-maximized");
driver = new ChromeDriver(options);

Note

If you ...

Get Selenium Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.