Book Image

Selenium Essentials

By : Prashanth Sams
Book Image

Selenium Essentials

By: Prashanth Sams

Overview of this book

Table of Contents (12 chapters)

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 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...