File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,6 @@ async def page_source(self) -> str:
9191 Returns:
9292 str: The source code of the page.
9393
94- TODO: tix this
9594 """
9695 response = await self ._execute_command (
9796 RuntimeCommands .evaluate_script (
@@ -100,6 +99,12 @@ async def page_source(self) -> str:
10099 )
101100 return response ['result' ]['result' ]['value' ]
102101
102+ async def close (self ):
103+ """
104+ Closes the page.
105+ """
106+ await self ._execute_command (PageCommands .close ())
107+
103108 async def get_cookies (self ) -> list [dict ]:
104109 """
105110 Retrieves the cookies of the page.
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ class PageCommands:
3131 'params' : {},
3232 }
3333 HANDLE_DIALOG = {'method' : 'Page.handleJavaScriptDialog' , 'params' : {}}
34+ CLOSE = {'method' : 'Page.close' }
3435
3536 @classmethod
3637 def handle_dialog (cls , accept : bool = True ) -> dict :
@@ -173,3 +174,14 @@ def disable_page(cls) -> dict:
173174 containing the method to disable the Page domain.
174175 """
175176 return cls .DISABLE_PAGE
177+
178+ @classmethod
179+ def close (cls ) -> dict :
180+ """
181+ Generates the command to close the current page.
182+
183+ Returns:
184+ dict: The command to be sent to the browser,
185+ containing the method to close the current page.
186+ """
187+ return cls .CLOSE
You can’t perform that action at this time.
0 commit comments