Class AnimatedGifManager
java.lang.Object
com.shaft.gui.internal.image.AnimatedGifManager
Manages the creation, frame-appending, and finalisation of animated GIF files that visualise
test execution steps in the SHAFT framework.
Each test thread gets its own GIF writer state through ThreadLocal fields, making
this class safe for parallel test execution. A new GIF is started automatically when the first
screenshot is captured; subsequent screenshots are appended as additional frames.
GIF creation is controlled by the SHAFT.Properties.visuals.createAnimatedGif() flag.
When disabled, all methods in this class are effectively no-ops.
Example (managed automatically by the SHAFT framework):
AnimatedGifManager.startOrAppendToAnimatedGif(screenshotBytes);
// ... test steps ...
String gifPath = AnimatedGifManager.attachAnimatedGif();
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringFinalises and attaches the current thread's animated GIF to the Allure report, then resets the thread-local GIF state so a new GIF can be started for the next test.static voidstartOrAppendToAnimatedGif(byte[] screenshot) Appends a screenshot frame to the current thread's animated GIF, or starts a new GIF if one has not yet been created for the current thread.
-
Method Details
-
attachAnimatedGif
Finalises and attaches the current thread's animated GIF to the Allure report, then resets the thread-local GIF state so a new GIF can be started for the next test.This method is a no-op when
SHAFT.Properties.visuals.createAnimatedGif()isfalseor when no GIF has been started for the current thread.Example:
String gifPath = AnimatedGifManager.attachAnimatedGif();- Returns:
- the relative file-system path of the attached GIF, or an empty string if nothing was attached
-
startOrAppendToAnimatedGif
public static void startOrAppendToAnimatedGif(byte[] screenshot) Appends a screenshot frame to the current thread's animated GIF, or starts a new GIF if one has not yet been created for the current thread.This method is a no-op when
SHAFT.Properties.visuals.createAnimatedGif()isfalse.Example:
byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); AnimatedGifManager.startOrAppendToAnimatedGif(screenshot);- Parameters:
screenshot- the raw PNG screenshot bytes to append as the next GIF frame; ifnullthe call is silently ignored
-