On Mon, 31 Mar 2025 18:35:03 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
>> Introduce a facility, in the form of JUnit5 annotation, to allow for >> capturing a desktop screenshot of a failed test. >> >> The primary intent is to be able to debug an intermittent test case, rather >> than wholesale addition of the new annotation to all the tests. >> >> The log contains a base-64 encoded screenshot (like this: >> `data:image/png;base64,iVBORw0KGgoAAAANSUhEU...` ) >> so it can be rendered in Safari (Chrome truncates the image possibly due to >> following a url length limit) >> >> Example: >> >>  > > Andy Goryachev has updated the pull request incrementally with one additional > commit since the last revision: > > data url Turns out one can't intercept assertion exceptions with `Thread.setDefaultUncaughtExceptionHandler()` (duh!), so this is likely to be a known limitation. We might still provide general purpose methods in `ScreenCapture` (new class) like /** * Captures a screenshot using JavaFX {@link Robot} in the PNG format. * <p> * This method can be called from any thread. If called from a thread other than * the JavaFX Application Thread, the current thread will be paused until the screenshot is taken. * * @return the byte array containing the screenshot * @throws IOException when an I/O error occurs */ public static byte[] takeScreenshot() throws IOException { and /** * Captures a screenshot using JavaFX {@link Robot} in the PNG format, * in the form of a Base-64 encoded {@code String}. * <p> * This method can be called from any thread. If called from a thread other than * the JavaFX Application Thread, the current thread will be paused until the screenshot is taken. * * @param prefix the string to append before the base-64 representation, or null * @param postfix the string to append after the base-64 representation, or null * @return the screenshot in Base-64 encoded PNG, or an error message */ public static String takeScreenshotBase64(String prefix, String postfix) { What do you think? ------------- PR Comment: https://git.openjdk.org/jfx/pull/1746#issuecomment-2770707191