Title: AllureSelenide attaches Screenshot and Page source once per nesting level of SelenideLogger.step · Issue #1453 · allure-framework/allure-java · GitHub
Open Graph Title: AllureSelenide attaches Screenshot and Page source once per nesting level of SelenideLogger.step · Issue #1453 · allure-framework/allure-java
X Title: AllureSelenide attaches Screenshot and Page source once per nesting level of SelenideLogger.step · Issue #1453 · allure-framework/allure-java
Description: What happened? Summary AllureSelenide.afterEvent attaches Screenshot and Page source on every SelenideLogger event with status FAIL. It never checks whether the same failure was already captured, so a single failure inside nested steps p...
Open Graph Description: What happened? Summary AllureSelenide.afterEvent attaches Screenshot and Page source on every SelenideLogger event with status FAIL. It never checks whether the same failure was already captured, s...
X Description: What happened? Summary AllureSelenide.afterEvent attaches Screenshot and Page source on every SelenideLogger event with status FAIL. It never checks whether the same failure was already captured, s...
Opengraph URL: https://github.com/allure-framework/allure-java/issues/1453
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AllureSelenide attaches Screenshot and Page source once per nesting level of SelenideLogger.step","articleBody":"### What happened?\n\n## Summary\n\n`AllureSelenide.afterEvent` attaches `Screenshot` and `Page source` on *every* SelenideLogger\nevent with status `FAIL`. It never checks whether the same failure was already captured, so a\nsingle failure inside nested steps produces one pair of attachments per nesting level.\n\n## Why it happens\n\n`afterEvent` captures unconditionally on FAIL:\n\n```java\npublic void afterEvent(final LogEvent event) {\n if (event.getStatus().equals(LogEvent.EventStatus.FAIL)) {\n lifecycle.getCurrentExecutableKey().ifPresent(owner -> {\n if (saveScreenshots) { ... addAttachment(owner, \"Screenshot\", ...) }\n if (savePageHtml) { ... addAttachment(owner, \"Page source\", ...) }\n```\n\n`SelenideLogger.step(...)` is itself a SelenideLogger event, and `SelenideLogger.wrap()`\ncommits it as FAIL again while the exception propagates outwards:\n\n```java\ncatch (RuntimeException | Error e) {\n SelenideLogger.commitStep(log, e); // -> afterEvent(FAIL) -> another screenshot\n throw e;\n}\n```\n\nSo the number of attachment pairs is (number of enclosing `SelenideLogger.step` calls) + 1.\n\n## How to reproduce\n\n```java\nSelenideLogger.addListener(\"allure\", new AllureSelenide().screenshots(true));\nSelenideLogger.step(\"outer step\", () -> SelenideLogger.step(\"inner step\", () -> $(\"#missing\").shouldBe(visible)));\n```\n\n### Actual\n\nThree `Screenshot` + `Page source` pairs for one failure:\n\n\n- [failed] $(\"outer step\") \u003c- Screenshot, Page source\n- - [failed] $(\"inner step\") \u003c- Screenshot, Page source\n- - - [failed] $(\"#missing\") should be(visible) \u003c- Screenshot, Page source\n\n### Expected\n\nOne `Screenshot` and one `Page source`, attached to the innermost step where the failure\nactually happened.\n\n## Impact\n\nThe duplicates are not copies — each one is a separate `getScreenshotAs` + `getPageSource`\nround trip to the driver. On a mobile/Appium setup that costs seconds per failure, and the\nlater screenshots are taken after the Selenide timeout has already elapsed, so they show a\ndifferent (less useful) state than the one that caused the failure. The report also becomes\nnoticeably harder to read: the reader has to figure out which of the identical-looking\nattachments is the relevant one.\n\nReproduces on 2.24.0 as well — the body of `afterEvent` is unchanged between 2.24.0 and\n3.0.0, only the lifecycle API around it has moved.\n\n## Note on the obvious workaround\n\nSkipping attachments for step wrappers (for example when `event.getSubject()` is empty) is\nnot sufficient. When non-Selenide code fails inside a `step()` — an assertion, an NPE, an API\nor messaging error — the wrapper's FAIL event is the *only* one, and that is exactly the case\nwhere a screenshot is most valuable. Deduplicating by the `Throwable` instead handles both\ncases, because `SelenideLogger.wrap()` rethrows the same instance (walking the `getCause()`\nchain also covers failures that get wrapped on the way out).\n\nI have a working implementation of this as a subclass in our own project, with tests for all\nfour cases (Selenide failure through a wrapper, wrapped-in-cause failure, assertion failure\ninside a wrapper, two distinct failures in one test).\n\n## Question before I send a PR\n\nWhich direction would you prefer?\n\n1. **Fix the default** — one attachment pair per failure, no new API. Cleaner, but changes\n behaviour for everyone on upgrade.\n2. **Add an opt-in** `deduplicateAttachments(boolean)`, default `false`. Safe, but users have\n to discover it.\n\nI'm ready to send a PR with unit tests for either — just let me know which one you'd accept.\n\nRelated: #1439 / #1440 touch `getScreenshotBytes()` in the same method, so there may be a\nsmall conflict; happy to rebase on top of that PR.\n\n### What Allure Integration are you using?\n\nallure-selenide\n\n### What version of Allure Integration you are using?\n\n3.0.0\n\n### What version of Allure Report you are using?\n\n2.19.0\n\n### Code of Conduct\n\n- [x] I agree to follow this project's Code of Conduct","author":{"url":"https://github.com/mikashee","@type":"Person","name":"mikashee"},"datePublished":"2026-10-09T14:44:34Z","url":"https://github.com/allure-framework/allure-java/issues/1453"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d9a56878-3e41-0891-c3aa-08b73bd03083 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A584:30AF58:2813121:37B5C64:6AFD481E |
| html-safe-nonce | fb08dd14bf9719824bd1485ff0c6cc6b255eb7660a3f630ca08bb6bfc4030a69 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTg0OjMwQUY1ODoyODEzMTIxOjM3QjVDNjQ6NkFGRDQ4MUUiLCJ2aXNpdG9yX2lkIjoiMzY5MTUzNjY3NjMxMzQ1MDUyNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 670aab33ffd37247ae3c3cbf015aa47605aad6413e6f4bb86b1f10201cd81b0a |
| hovercard-subject-tag | issue:5779973930 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/allure-framework/allure-java/1453/issue_layout |
| twitter:image | https://opengraph.githubassets.com/957fe2561dbf0f6590add386202f4a24af8af1e55ae82609510befb4db88c7c2/allure-framework/allure-java/issues/1453 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/957fe2561dbf0f6590add386202f4a24af8af1e55ae82609510befb4db88c7c2/allure-framework/allure-java/issues/1453 |
| og:image:alt | What happened? Summary AllureSelenide.afterEvent attaches Screenshot and Page source on every SelenideLogger event with status FAIL. It never checks whether the same failure was already captured, s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mikashee |
| hostname | github.com |
| expected-hostname | github.com |
| None | bdbacc25b921224ff0befcb9e629560a1255be51aec9991d6e3f95b5e9151474 |
| turbo-cache-control | no-preview |
| go-import | github.com/allure-framework/allure-java git https://github.com/allure-framework/allure-java.git |
| octolytics-dimension-user_id | 5879127 |
| octolytics-dimension-user_login | allure-framework |
| octolytics-dimension-repository_id | 80822758 |
| octolytics-dimension-repository_nwo | allure-framework/allure-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 80822758 |
| octolytics-dimension-repository_network_root_nwo | allure-framework/allure-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 556dd37bb0aceffb25724e151b5d858b3265b40b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width