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);
If you face an error such as org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
, then create a new Chrome profile and execute the tests.
To get more information on the user data location (for different OS platforms), refer to http://www.chromium.org/user-experience/user-data-directory.
The following are the steps to create a custom Chrome profile:
User Data
folder (located at C:/Users/user_name/AppData/Local/Google/Chrome/User Data
) and paste it in the same folder with a different name (for example, New User
).New User
folder.Default
folder, so that after your test run, a new folder named Default
is created.C:/Users/user_name/AppData/Local/Google/Chrome/New User
.