Wednesday, June 3, 2020

Store Chrome And Firefox Driver Log

Some time we need to write driver log to understand the issue in more deeply, for that reason we can write or store the driver log on any log file.

Step 1:

Create a driver service with log file path like below :

For Chrome

ChromeDriverService services = new ChromeDriverService.Builder().withSilent(false).withLogFile(new File("./src/test/resources/chrome.log")).build();

For Firefox

GeckoDriverService service = new GeckoDriverService.Builder().withLogFile(new File("./src/test/resources/firefox.log")).build();

Step 2:

Now pass the service parameter to WebDriver Instance.

WebDriver driver = new ChromeDriver(services);