How to enable verbose browser console logs

When a test case is ran, by default verbose browser console logs are not on (as seen if you press F12 and choose default levels at the console) , is there a way to enable verbose console logging ? (using chrome as browser)

Thanks

So this is where I got to with this, but it does not seem desired capabilities are taken in to account. Katalon explicitly tells me verbose logging is enabled but it is not.

Possibly linked to this raised by others, on a side note the documentation around desired capabilities sucks :stuck_out_tongue:

import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import java.util.logging.Level
import org.junit.After
import org.openqa.selenium.WebDriver
import org.openqa.selenium.logging.LogEntries
import org.openqa.selenium.logging.LogEntry
import org.openqa.selenium.logging.LogType
import org.openqa.selenium.logging.LoggingPreferences
import org.openqa.selenium.remote.CapabilityType
import org.openqa.selenium.remote.DesiredCapabilities
import com.kms.katalon.core.logging.KeywordLogger as KeywordLogger
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
KeywordLogger log = new KeywordLogger()
DesiredCapabilities caps = DesiredCapabilities.chrome()
LoggingPreferences logPrefs = new LoggingPreferences()
logPrefs.enable(LogType.BROWSER, Level.ALL)
caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs)

WebUI.openBrowser('')
public void appendBrowserLogs() {
WebDriver driver = DriverFactory.getWebDriver()
LogEntries logs = driver.manage().logs().get('browser')
KeywordLogger log = new KeywordLogger()
for (LogEntry logEntry : logs) {
if (logEntry.getMessage().toLowerCase().contains('error')) {
log.logInfo(helper + ' - Error Message in Console:' + logEntry.getMessage())
} else {
log.logInfo(helper + ' - Message in Console:' + logEntry.getMessage())
}
}
}
appendBrowserLogs()

2.png

1.png

1 Like