Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Macro
Cyber Security

Macro

← Back to Glossary
By NHI Mgmt Group Updated September 24, 2026 Domain: Cyber Security

A macro is a predefined JavaScript function that runs at a specific moment during screenshot automation. In this context, it prepares the page by removing elements, changing state, or adding annotations before capture. Macros help teams produce consistent screenshots without manual browser editing.

What a Macro Is in Screenshot Automation

A macro is a small, predefined JavaScript routine that runs at a specific stage of screenshot capture. It is not the screenshot tool itself, but the scripted step that prepares the page so the resulting image is consistent and repeatable.

Because macros execute before capture, they are best understood as a controlled automation hook. Teams use them to remove transient UI, normalise page state, or add annotations so the screenshot reflects what they actually want to document or test.

Where Macros Fit in the Capture Workflow

Macros sit between page load and image creation. That timing matters because screenshot workflows often need to eliminate moving parts such as popups, live widgets, timestamps, cookie banners, or expandable panels that would otherwise change the output from run to run.

In practice, the macro becomes part of the capture pipeline. It can hide elements, adjust layout conditions, or trigger a known page state before the browser takes the image. The result is a more stable automation flow and fewer manual edits after capture.

What Macros Commonly Do

The most common macro actions are page cleanup and state shaping. A macro may remove distracting elements, set a viewport or theme state, expand content that is otherwise collapsed, or inject labels and callouts for documentation purposes.

That flexibility is useful, but it also means the macro is shaping the evidence, not simply recording it. The screenshot reflects the logic in the macro as much as it reflects the page itself, so the routine should be treated as part of the artifact generation process.

Why Macros Matter for Repeatable Screenshots

Macros make screenshot automation more reliable when the page under capture is dynamic. Without them, teams often end up with inconsistent visual output because banners, animations, user-specific elements, or timing differences alter the final image.

Used well, a macro reduces manual intervention and improves consistency across environments, browsers, and test runs. Used poorly, it can hide important page content or create a misleading snapshot of the actual user experience.

Risk and Threat Considerations

Screenshot macros are small pieces of executable JavaScript, so they can become a trust boundary if they are reused across projects or maintained by people who are not close to the page content. A macro that removes too much, runs at the wrong time, or is modified without review can distort the screenshot and conceal content that should have been visible.

Failure mechanism: The capture pipeline executes scripted page manipulation before the image is taken, and that logic can suppress, alter, or replace elements in ways that are hard to notice in review.

Impact: Teams may publish inaccurate documentation, miss UI regressions, or create a false sense of consistency when the macro is actually masking page-state differences.

Practitioner Guidance

Why practitioners should care: Treat the macro as part of the screenshot control surface, not as a harmless convenience script. The more it changes page state, the more important it becomes to review it like other automation that affects evidence, test output, or published visuals.

Common misunderstanding: A clean screenshot is not always a faithful screenshot. If the macro hides transient elements, the output may be useful for documentation while still being a poor representation of the live page.

Practitioner takeaway: Keep macro logic small, explicit, and easy to audit so the team can tell when the capture is preserving the page and when it is materially transforming it.

Deepen Your Knowledge

Sign up to our weekly newsletter — get 33% off our NHI Foundation Level Course

    NHIMG Editorial Note
    Reviewed and updated by the NHIMG editorial team on September 24, 2026.
    NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org