Skip to content

fix screenshot env bb #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "stagehand"
version = "0.0.5"
version = "0.0.6"
description = "Python SDK for Stagehand"
readme = "README.md"
license = {text = "MIT"}
Expand Down
27 changes: 0 additions & 27 deletions stagehand/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,33 +374,6 @@ async def extract(
)
return result_dict

async def screenshot(self, options: Optional[dict] = None) -> str:
"""
Take a screenshot of the current page via the Stagehand server.

Args:
options (Optional[dict]): Optional screenshot options.
May include:
- type: "png" or "jpeg" (default: "png")
- fullPage: whether to take a full page screenshot (default: False)
- quality: for jpeg only, 0-100 (default: 80)
- clip: viewport clip rectangle
- omitBackground: whether to hide default white background (default: False)

Returns:
str: Base64-encoded screenshot data.
"""
payload = options or {}

if self._stagehand.use_api:
lock = self._stagehand._get_lock_for_session()
async with lock:
result = await self._stagehand._execute("screenshot", payload)

return result
else:
return await self._page.screenshot(**payload)

# Method to get or initialize the persistent CDP client
async def get_cdp_client(self) -> CDPSession:
"""Gets the persistent CDP client, initializing it if necessary."""
Expand Down