88from pydoll .browser .firefox .element import KEYS , FirefoxElement
99from pydoll .protocol .bidi import browsing_context , network , script , session , storage
1010from pydoll .protocol .bidi import input as bidi_input
11- from pydoll .protocol .bidi .network import InterceptPhase , NetworkEvent
11+ from pydoll .protocol .bidi .network import Header , InterceptPhase , NetworkEvent
1212
1313if TYPE_CHECKING :
1414 from pydoll .connection .bidi_connection_handler import BiDiConnectionHandler
@@ -54,7 +54,7 @@ async def go_to(self, url: str, wait: str = 'complete') -> dict:
5454 Navigation result dict with 'url' key.
5555 """
5656 logger .info (f'Navigating to { url } (context={ self ._context_id } )' )
57- response = await self ._connection_handler .execute_command (
57+ response : dict = await self ._connection_handler .execute_command (
5858 browsing_context .navigate (self ._context_id , url , wait )
5959 )
6060 return response ['result' ]
@@ -71,7 +71,7 @@ async def evaluate(self, expression: str, await_promise: bool = True) -> Any:
7171 The JavaScript result value.
7272 """
7373 logger .debug (f'Evaluating expression in context={ self ._context_id } ' )
74- response = await self ._connection_handler .execute_command (
74+ response : dict = await self ._connection_handler .execute_command (
7575 script .evaluate (expression , self ._context_id , await_promise )
7676 )
7777 result = response .get ('result' , {})
@@ -100,7 +100,7 @@ async def find(
100100 f'Finding nodes: selector={ selector !r} , type={ selector_type } , '
101101 f'context={ self ._context_id } '
102102 )
103- response = await self ._connection_handler .execute_command (
103+ response : dict = await self ._connection_handler .execute_command (
104104 browsing_context .locate_nodes (self ._context_id , locator , max_node_count )
105105 )
106106 nodes = response .get ('result' , {}).get ('nodes' , [])
@@ -114,7 +114,7 @@ async def take_screenshot(self) -> bytes:
114114 PNG screenshot as bytes.
115115 """
116116 logger .debug (f'Taking screenshot: context={ self ._context_id } ' )
117- response = await self ._connection_handler .execute_command (
117+ response : dict = await self ._connection_handler .execute_command (
118118 browsing_context .capture_screenshot (self ._context_id )
119119 )
120120 data = response .get ('result' , {}).get ('data' , '' )
@@ -209,7 +209,7 @@ async def get_cookies(self) -> list[dict]:
209209 httpOnly, secure, sameSite, expiry, etc.
210210 """
211211 logger .debug (f'Getting cookies: context={ self ._context_id } ' )
212- response = await self ._connection_handler .execute_command (
212+ response : dict = await self ._connection_handler .execute_command (
213213 storage .get_cookies (self ._context_id )
214214 )
215215 return response .get ('result' , {}).get ('cookies' , [])
@@ -314,7 +314,7 @@ async def refresh(self, wait: str = 'complete') -> dict:
314314 Reload result dict with 'url' key.
315315 """
316316 logger .info (f'Refreshing context={ self ._context_id } ' )
317- response = await self ._connection_handler .execute_command (
317+ response : dict = await self ._connection_handler .execute_command (
318318 browsing_context .reload (self ._context_id , wait )
319319 )
320320 return response .get ('result' , {})
@@ -327,7 +327,7 @@ async def go_back(self) -> dict:
327327 TraverseHistory result dict.
328328 """
329329 logger .info (f'Going back: context={ self ._context_id } ' )
330- response = await self ._connection_handler .execute_command (
330+ response : dict = await self ._connection_handler .execute_command (
331331 browsing_context .traverse_history (self ._context_id , delta = - 1 )
332332 )
333333 return response .get ('result' , {})
@@ -340,7 +340,7 @@ async def go_forward(self) -> dict:
340340 TraverseHistory result dict.
341341 """
342342 logger .info (f'Going forward: context={ self ._context_id } ' )
343- response = await self ._connection_handler .execute_command (
343+ response : dict = await self ._connection_handler .execute_command (
344344 browsing_context .traverse_history (self ._context_id , delta = 1 )
345345 )
346346 return response .get ('result' , {})
@@ -388,7 +388,7 @@ async def add_intercept(
388388 if phases is None :
389389 phases = [InterceptPhase .BEFORE_REQUEST_SENT ]
390390 logger .info (f'Adding intercept phases={ phases } : context={ self ._context_id } ' )
391- response = await self ._connection_handler .execute_command (
391+ response : dict = await self ._connection_handler .execute_command (
392392 network .add_intercept (
393393 phases = phases ,
394394 contexts = [self ._context_id ],
@@ -407,7 +407,7 @@ async def continue_request(
407407 request_id : str ,
408408 url : Optional [str ] = None ,
409409 method : Optional [str ] = None ,
410- headers : Optional [list [dict ]] = None ,
410+ headers : Optional [list [Header ]] = None ,
411411 body : Optional [str ] = None ,
412412 ) -> None :
413413 """
@@ -440,7 +440,7 @@ async def provide_response(
440440 self ,
441441 request_id : str ,
442442 status_code : int = 200 ,
443- headers : Optional [list [dict ]] = None ,
443+ headers : Optional [list [Header ]] = None ,
444444 body : Optional [str ] = None ,
445445 reason_phrase : Optional [str ] = None ,
446446 ) -> None :
@@ -468,7 +468,7 @@ async def continue_response(
468468 self ,
469469 request_id : str ,
470470 status_code : Optional [int ] = None ,
471- headers : Optional [list [dict ]] = None ,
471+ headers : Optional [list [Header ]] = None ,
472472 reason_phrase : Optional [str ] = None ,
473473 ) -> None :
474474 """
@@ -526,7 +526,7 @@ async def new_tab(self, url: str = '') -> FirefoxTab:
526526 New FirefoxTab instance.
527527 """
528528 logger .info ('Creating new tab' )
529- response = await self ._connection_handler .execute_command (browsing_context .create ())
529+ response : dict = await self ._connection_handler .execute_command (browsing_context .create ())
530530 context_id = response ['result' ]['context' ]
531531 tab = FirefoxTab (context_id , self ._connection_handler )
532532 if url :
0 commit comments