For example, suppose I need to test a canvas-based web page (eg: a game), after pressing a button on the canvas, the console would output a statement for example : console.log(“Button A pressed”); , does Katalon Studio have some functions that assert if the last output string of the console is “Button A pressed”?
hi @maxfair
why don’t you create one using custom keywords?
claude code gave me this example to try:
package com.example.keywords
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.webui.driver.DriverFactory
import org.openqa.selenium.WebDriver
import org.openqa.selenium.logging.LogEntry
import org.openqa.selenium.logging.LogType
public class ConsoleLogKeywords {
private static List<LogEntry> cachedLogs = []
@Keyword
def getConsoleLogs(boolean clearCache = true) {
WebDriver driver = DriverFactory.getWebDriver()
List<LogEntry> logs = driver.manage().logs().get(LogType.BROWSER).getAll()
if (clearCache) {
cachedLogs = logs
} else {
cachedLogs.addAll(logs)
}
return cachedLogs
}
@Keyword
def verifyLastConsoleMessage(String expectedMessage, boolean exactMatch = false) {
def logs = getConsoleLogs()
if (logs.isEmpty()) {
throw new AssertionError("No console logs found")
}
String lastMessage = logs.last().getMessage()
if (exactMatch) {
assert lastMessage == expectedMessage : "Expected: '${expectedMessage}' but got: '${lastMessage}'"
} else {
assert lastMessage.contains(expectedMessage) : "Console log doesn't contain '${expectedMessage}'. Got: '${lastMessage}'"
}
return true
}
@Keyword
def verifyConsoleContains(String expectedMessage) {
def logs = getConsoleLogs()
boolean found = logs.any { it.getMessage().contains(expectedMessage) }
assert found : "No console log containing '${expectedMessage}' found"
return true
}
@Keyword
def waitForConsoleMessage(String expectedMessage, int timeoutSeconds = 10) {
long endTime = System.currentTimeMillis() + (timeoutSeconds * 1000)
while (System.currentTimeMillis() < endTime) {
def logs = getConsoleLogs(false)
if (logs.any { it.getMessage().contains(expectedMessage) }) {
return true
}
Thread.sleep(500)
}
throw new AssertionError("Console message '${expectedMessage}' not found within ${timeoutSeconds}s")
}
}
save this to Keywords/com/example/keywords/ConsoleLogKeywords.groovy and use it like:
// Click your canvas button
WebUI.click(findTestObject('Page_Game/canvas_game'))
// Then verify
CustomKeywords.'com.example.keywords.ConsoleLogKeywords.verifyLastConsoleMessage'('Button A pressed')
// Or if timing is unpredictable:
CustomKeywords.'com.example.keywords.ConsoleLogKeywords.waitForConsoleMessage'('Button A pressed', 5)
There’s no built‑in “Verify last console output” keyword in Katalon Studio, but you can achieve it easily with a small custom keyword that reads the browser console logs via WebDriver as explained above
What do you mean by “console”?
Do you mean it the console object in JavaScript language? something like:
Or is it the “Console” tab visible in the Katalon Studio GUI?
I believe that @depapp was talking about the Console tab of Katalon Studio GUI. If @maxfair want to read the message emitted by console.log(msg) in Javascript of the web page under test, @depapp’s suggestion will fall besides the point.
If @maxfair wants to read the message emitted by console.log(msg) in JavaScript, unfortunately Katalon Studo does not provide a way to do that easily.
There were several hacks previously discussed, but these were too much complicated. See
or
The previous discussion might not work today with the recent Katalon and browser versions.
As explained in Exploring Selenium BiDi Functionality | Awesome Testing , Selenium 4 supports Chrome DevTools protocol (CDP) which Katalon Studio v10 runs upon. With CDP, the console message should be accessible for the API clients. However I don’t know if it is possible for tests in Katalon Studio to listen to javascript errors in console. Katalon has not published any tutorial how to use CDP features in Katalon Studio v10. I suppose it would be tough to try it out.
By the way, using Playwright, you can achieve what you want to do easily. See

