i have 20 baseline images in katalon studio but while executing a testsuite it is taking only 8 screenshots . actually it need to compare only to that 8 screenshots but it is comparing with all the images in baseline and throwing error message as 12 images are missing in katalon studio
To resolve the missing baseline image errors in Katalon Studioβs Visual Testing when only 8 screenshots are needed (but Katalon checks all 20 baseline images), follow these steps:
1. Organize Baseline Images by Test Suite/Case
Problem: Katalon checks all images in the baseline folder by default.
Solution: Create subfolders in the Baseline
directory to isolate images per test suite/case.
- Directory Structure:
Baseline/
βββ TestSuite1/
β βββ screenshot1.png
β βββ screenshot2.png
βββ TestSuite2/
βββ screenshotA.png
βββ screenshotB.png
- Code: Use the
relativeFolderPath
parameter inverifyMatchBaseline
:
WebUI.takeScreenshot('screenshot1.png')
WebUI.verifyMatchBaseline('screenshot1.png', 'TestSuite1/screenshot1.png')
2. Delete Unused Baseline Images
If the test suite needs only 8 images, remove extra images from the baseline folder:
- Go to
Katalon Studio > Baseline
folder. - Delete the 12 unused images.
3. Use Checkpoints with Unique Names
Ensure each screenshot has a unique name tied to a specific test step to avoid overlaps:
// Example for Test Case 1
WebUI.takeScreenshot('TC1_LoginPage.png')
WebUI.verifyMatchBaseline('TC1_LoginPage.png', 'TestSuite1/TC1_LoginPage.png')
4. Configure Checkpoint Scope
If using Test Suite-Specific Baselines, add this logic to your test cases:
// At the start of the test suite
String baselineFolder = 'TestSuite1' // Dynamically set based on test context
// When verifying
WebUI.verifyMatchBaseline('screenshot1.png', "${baselineFolder}/screenshot1.png")
5. Troubleshoot Capture Failures
If some screenshots arenβt captured during execution:
- Add Explicit Waits to ensure elements load:
WebUI.waitForElementVisible(findTestObject('Page_Element'), 10)
WebUI.takeScreenshot()
- Enable Screenshot on Failure in
Keywords/Test Listeners
:
@AfterTestCase
def afterTestCase(TestCaseContext testCaseContext) {
if (testCaseContext.getTestCaseStatus() == 'FAILED') {
WebUI.takeScreenshot()
}
}
6. Clean and Rebuild Baselines
- Delete all baselines:
// Use Katalonβs built-in baseline cleanup or manually delete via file explorer
- Rebuild baselines for the 8 required images by re-running the test in Baseline Mode:
- In
test-execution.properties
, set:
visual.enable=true
visual.baseline.mode=true
Key Notes:
- Avoid Generic Names: Names like
screenshot1.png
can conflict. Use descriptive names (e.g.,LoginPage_Header.png
). - Update Baselines: If your UI changes, rebuild baselines instead of tolerating mismatches.
- Use the Katalon Visual Testing Docs for advanced settings:
Visual Testing Documentation
Thanks a lot for sharing it really helps a lot . I have a last query
I have created baseline folders from testops and validating screenshots via testops only.
Does the above code also work same there as well right or do i need to any advance settings in my code
Also the method your using WebUI.takeScreenshot(βTC1_LoginPage.pngβ)
but as per visual testing documentation we need to use the below right
WebUI.takeFullPageScreenshotAsCheckpoint().
Based on my understanding the above one works fell for local testing but we are doing via TestOPS so do i need to do any changes in the code
Bump the topic to let more experts get involved in helping.