Skip to content

Commit 433b2fc

Browse files
committed
feat: add Response type and new bring_to_front method to Tab class
1 parent 4b55a9e commit 433b2fc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pydoll/browser/tab.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
PageLoadTimeout,
4747
WaitElementTimeout,
4848
)
49-
from pydoll.protocol.base import EmptyResponse
49+
from pydoll.protocol.base import EmptyResponse, Response
5050
from pydoll.protocol.browser.events import (
5151
BrowserEvent,
5252
DownloadProgressEvent,
@@ -282,7 +282,7 @@ async def enable_fetch_events(
282282
Note:
283283
Intercepted requests must be explicitly continued or timeout.
284284
"""
285-
response: EmptyResponse = await self._execute_command(
285+
response: Response[EmptyResponse] = await self._execute_command(
286286
FetchCommands.enable(
287287
handle_auth_requests=handle_auth,
288288
resource_type=resource_type,
@@ -424,6 +424,10 @@ async def get_frame(self, frame: WebElement) -> IFrame:
424424

425425
return Tab(self._browser, self._connection_port, iframe_target['targetId'])
426426

427+
async def bring_to_front(self):
428+
"""Brings the page to front."""
429+
return await self._execute_command(PageCommands.bring_to_front())
430+
427431
async def get_cookies(self) -> list[Cookie]:
428432
"""Get all cookies accessible from current page."""
429433
response: GetCookiesResponse = await self._execute_command(
@@ -545,6 +549,7 @@ async def take_screenshot(
545549
self,
546550
path: Optional[str] = None,
547551
quality: int = 100,
552+
beyond_viewport: bool = False,
548553
as_base64: bool = False,
549554
) -> Optional[str]:
550555
"""
@@ -553,6 +558,8 @@ async def take_screenshot(
553558
Args:
554559
path: File path for screenshot (extension determines format).
555560
quality: Image quality 0-100 (default 100).
561+
beyond_viewport: The page will be scrolled to the bottom and the screenshot will
562+
include the entire page
556563
as_base64: Return as base64 string instead of saving file.
557564
558565
Returns:
@@ -573,6 +580,7 @@ async def take_screenshot(
573580
PageCommands.capture_screenshot(
574581
format=ScreenshotFormat.get_value(output_extension),
575582
quality=quality,
583+
capture_beyond_viewport=beyond_viewport,
576584
)
577585
)
578586
screenshot_data = response['result']['data']

0 commit comments

Comments
 (0)