adbo
adbo

Reputation: 807

How to enable verbose logging in ChromeDriver? (GebConfig)

I have to enable verbose logging in Chrome / ChromeDriver to see why my geb tests are failing. Does anybody know how I can do that. Heres my GebConfig:

String chromeDriverDownloadFullPath = "https://chromedriver.storage.googleapis.com/${chromeDriverVersion}/${chromeDriverZipFileName}"
File chromeDriverLocalFile = downloadDriver(
        currentPlatformName,
        chromeDriverDownloadFullPath,
        chromeDriverExecFileName,
        'zip',
        "chrome",
        chromeDriverVersion)

System.setProperty('webdriver.chrome.driver', chromeDriverLocalFile.absolutePath)

Locale locale = getLocale()
ChromeOptions options = new ChromeOptions();
options.addArguments("--lang=" + locale.country);
options.addArguments("--headless");
options.addArguments("--disable-gpu");
options.addArguments("--no-sandbox");
options.addArguments("--user-data-dir=/data");


DesiredCapabilities jsCapabilities = DesiredCapabilities.chrome()
Map<String, Object> prefs = new HashMap<>()
prefs.put("intl.accept_languages", locale.toLanguageTag())
options.setExperimentalOption("prefs", prefs)
jsCapabilities.setCapability(ChromeOptions.CAPABILITY, options)

ChromeDriver chromeDriver = new ChromeDriver(options)
chromeDriver.manage().window().setSize(getDimension())
return chromeDriver

Upvotes: 4

Views: 11487

Answers (2)

undetected Selenium
undetected Selenium

Reputation: 193108

To obtain verbose logs from ChromeDriver we can configure the logfile and the type_of_logging as follows:

System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
System.setProperty("webdriver.chrome.logfile", "C:\\Utility\\BrowserDrivers\\chromedriver.log");
System.setProperty("webdriver.chrome.verboseLogging", "true");

Update :

I can see from your code you have provided :

System.setProperty('webdriver.chrome.driver', chromeDriverLocalFile.absolutePath) 

In a similar fashion try to provide :

System.setProperty('webdriver.chrome.logfile', chromeDriverLocalFile.absolutePath);
System.setProperty('webdriver.chrome.verboseLogging', boolean);

Upvotes: 5

iamsankalp89
iamsankalp89

Reputation: 4739

From the documentation of ChromeDriver - WebDriver for Chrome

System.setProperty("webdriver.chrome.logfile", "Your path");
System.setProperty("webdriver.chrome.verboseLogging", "true");

Upvotes: 0

Related Questions