Problem
The screenshot() method in handler/page.rs unconditionally calls self.activate() before capturing:
https://github.com/mattsse/chromiumoxide/blob/main/src/handler/page.rs#L387
pub async fn screenshot(&self, params: impl Into<ScreenshotParams>) -> Result<Vec<u8>> {
self.activate().await?; // sends ActivateTargetParams
// ...
}
This sends Target.activateTarget via CDP, which brings the browser window to the OS foreground on every screenshot. For automation agents that take screenshots every few seconds (e.g. after each action), this makes the browser repeatedly steal focus from whatever the user is working on.
Expected behavior
CaptureScreenshot works fine via CDP without activating the target first — the screenshot is captured from the page's render tree regardless of window focus. The activate() call is unnecessary for single-tab use cases and harmful for headful automation where the user wants to multitask.
Suggested fix
Either:
- Remove the
activate() call from screenshot() entirely, or
- Make it opt-in via a parameter on
ScreenshotParams (e.g. activate_before_capture)
Workaround
Calling page.execute(CaptureScreenshotParams { format: Some(Png), .. }) directly bypasses the issue.
Environment
- chromiumoxide 0.8.0
- macOS (though the issue applies to any OS where
Target.activateTarget brings the window to front)
Problem
The
screenshot()method inhandler/page.rsunconditionally callsself.activate()before capturing:https://github.com/mattsse/chromiumoxide/blob/main/src/handler/page.rs#L387
This sends
Target.activateTargetvia CDP, which brings the browser window to the OS foreground on every screenshot. For automation agents that take screenshots every few seconds (e.g. after each action), this makes the browser repeatedly steal focus from whatever the user is working on.Expected behavior
CaptureScreenshotworks fine via CDP without activating the target first — the screenshot is captured from the page's render tree regardless of window focus. Theactivate()call is unnecessary for single-tab use cases and harmful for headful automation where the user wants to multitask.Suggested fix
Either:
activate()call fromscreenshot()entirely, orScreenshotParams(e.g.activate_before_capture)Workaround
Calling
page.execute(CaptureScreenshotParams { format: Some(Png), .. })directly bypasses the issue.Environment
Target.activateTargetbrings the window to front)