Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 658
adbo Avatar asked Oct 12 '25 07:10

adbo


1 Answers

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);
like image 149
undetected Selenium Avatar answered Oct 15 '25 04:10

undetected Selenium