osn-selenium 0.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- osn_selenium/__init__.py +1 -0
- osn_selenium/browsers_handler/__init__.py +70 -0
- osn_selenium/browsers_handler/_windows.py +130 -0
- osn_selenium/browsers_handler/types.py +20 -0
- osn_selenium/captcha_workers/__init__.py +26 -0
- osn_selenium/dev_tools/__init__.py +1 -0
- osn_selenium/dev_tools/_types.py +22 -0
- osn_selenium/dev_tools/domains/__init__.py +63 -0
- osn_selenium/dev_tools/domains/abstract.py +378 -0
- osn_selenium/dev_tools/domains/fetch.py +1295 -0
- osn_selenium/dev_tools/domains_default/__init__.py +1 -0
- osn_selenium/dev_tools/domains_default/fetch.py +155 -0
- osn_selenium/dev_tools/errors.py +89 -0
- osn_selenium/dev_tools/logger.py +558 -0
- osn_selenium/dev_tools/manager.py +1551 -0
- osn_selenium/dev_tools/utils.py +509 -0
- osn_selenium/errors.py +16 -0
- osn_selenium/types.py +118 -0
- osn_selenium/webdrivers/BaseDriver/__init__.py +1 -0
- osn_selenium/webdrivers/BaseDriver/_utils.py +37 -0
- osn_selenium/webdrivers/BaseDriver/flags.py +644 -0
- osn_selenium/webdrivers/BaseDriver/protocols.py +2135 -0
- osn_selenium/webdrivers/BaseDriver/trio_wrapper.py +71 -0
- osn_selenium/webdrivers/BaseDriver/webdriver.py +2626 -0
- osn_selenium/webdrivers/Blink/__init__.py +1 -0
- osn_selenium/webdrivers/Blink/flags.py +1349 -0
- osn_selenium/webdrivers/Blink/protocols.py +330 -0
- osn_selenium/webdrivers/Blink/webdriver.py +637 -0
- osn_selenium/webdrivers/Chrome/__init__.py +1 -0
- osn_selenium/webdrivers/Chrome/flags.py +192 -0
- osn_selenium/webdrivers/Chrome/protocols.py +228 -0
- osn_selenium/webdrivers/Chrome/webdriver.py +394 -0
- osn_selenium/webdrivers/Edge/__init__.py +1 -0
- osn_selenium/webdrivers/Edge/flags.py +192 -0
- osn_selenium/webdrivers/Edge/protocols.py +228 -0
- osn_selenium/webdrivers/Edge/webdriver.py +394 -0
- osn_selenium/webdrivers/Yandex/__init__.py +1 -0
- osn_selenium/webdrivers/Yandex/flags.py +192 -0
- osn_selenium/webdrivers/Yandex/protocols.py +211 -0
- osn_selenium/webdrivers/Yandex/webdriver.py +350 -0
- osn_selenium/webdrivers/__init__.py +1 -0
- osn_selenium/webdrivers/_functions.py +504 -0
- osn_selenium/webdrivers/js_scripts/check_element_in_viewport.js +18 -0
- osn_selenium/webdrivers/js_scripts/get_document_scroll_size.js +4 -0
- osn_selenium/webdrivers/js_scripts/get_element_css.js +6 -0
- osn_selenium/webdrivers/js_scripts/get_element_rect_in_viewport.js +9 -0
- osn_selenium/webdrivers/js_scripts/get_random_element_point_in_viewport.js +59 -0
- osn_selenium/webdrivers/js_scripts/get_viewport_position.js +4 -0
- osn_selenium/webdrivers/js_scripts/get_viewport_rect.js +6 -0
- osn_selenium/webdrivers/js_scripts/get_viewport_size.js +4 -0
- osn_selenium/webdrivers/js_scripts/open_new_tab.js +1 -0
- osn_selenium/webdrivers/js_scripts/stop_window_loading.js +1 -0
- osn_selenium/webdrivers/types.py +390 -0
- osn_selenium-0.0.0.dist-info/METADATA +710 -0
- osn_selenium-0.0.0.dist-info/RECORD +57 -0
- osn_selenium-0.0.0.dist-info/WHEEL +5 -0
- osn_selenium-0.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1295 @@
|
|
|
1
|
+
import trio
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from osn_selenium.dev_tools.utils import (
|
|
4
|
+
cdp_end_exceptions,
|
|
5
|
+
execute_cdp_command
|
|
6
|
+
)
|
|
7
|
+
from osn_selenium.dev_tools.domains_default.fetch import (
|
|
8
|
+
auth_required_choose_func,
|
|
9
|
+
request_paused_choose_func
|
|
10
|
+
)
|
|
11
|
+
from typing import (
|
|
12
|
+
Any,
|
|
13
|
+
Awaitable,
|
|
14
|
+
Callable,
|
|
15
|
+
Literal,
|
|
16
|
+
Mapping,
|
|
17
|
+
Optional,
|
|
18
|
+
Sequence,
|
|
19
|
+
TYPE_CHECKING,
|
|
20
|
+
TypedDict
|
|
21
|
+
)
|
|
22
|
+
from osn_selenium.dev_tools.domains.abstract import (
|
|
23
|
+
AbstractAction,
|
|
24
|
+
AbstractActionParametersHandlersSettings,
|
|
25
|
+
AbstractActionSettings,
|
|
26
|
+
AbstractDomain,
|
|
27
|
+
AbstractDomainEnableKwargsSettings,
|
|
28
|
+
AbstractDomainHandlersSettings,
|
|
29
|
+
AbstractDomainSettings,
|
|
30
|
+
AbstractEvent,
|
|
31
|
+
AbstractEventActionsHandler,
|
|
32
|
+
AbstractEventActionsHandlerSettings,
|
|
33
|
+
AbstractEventActionsSettings,
|
|
34
|
+
AbstractEventSettings,
|
|
35
|
+
ParameterHandler,
|
|
36
|
+
build_kwargs_from_handlers_func_type,
|
|
37
|
+
kwargs_type,
|
|
38
|
+
on_error_func_type,
|
|
39
|
+
response_handle_func_type
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if TYPE_CHECKING:
|
|
44
|
+
from osn_selenium.dev_tools.manager import DevToolsTarget
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class _ContinueWithAuthParametersHandlers(TypedDict):
|
|
48
|
+
"""
|
|
49
|
+
Internal TypedDict for handlers related to the 'continueWithAuth' action.
|
|
50
|
+
|
|
51
|
+
Attributes:
|
|
52
|
+
response (ParameterHandler): Handler for the auth challenge response.
|
|
53
|
+
username (Optional[ParameterHandler]): Handler for providing the username.
|
|
54
|
+
password (Optional[ParameterHandler]): Handler for providing the password.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
response: ParameterHandler
|
|
58
|
+
username: Optional[ParameterHandler]
|
|
59
|
+
password: Optional[ParameterHandler]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass
|
|
63
|
+
class ContinueWithAuthParameterHandlersSettings(AbstractActionParametersHandlersSettings):
|
|
64
|
+
"""
|
|
65
|
+
Settings for the handlers that provide authentication credentials when required.
|
|
66
|
+
|
|
67
|
+
Attributes:
|
|
68
|
+
response (ParameterHandler): Handler for the authentication challenge response. This handler determines the response type (e.g., default, custom credentials, or canceled).
|
|
69
|
+
username (Optional[ParameterHandler]): Optional handler for providing the username if using custom credentials. Defaults to None.
|
|
70
|
+
password (Optional[ParameterHandler]): Optional handler for providing the password if using custom credentials. Defaults to None.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
response: ParameterHandler
|
|
74
|
+
username: Optional[ParameterHandler] = None
|
|
75
|
+
password: Optional[ParameterHandler] = None
|
|
76
|
+
|
|
77
|
+
def to_dict(self) -> _ContinueWithAuthParametersHandlers:
|
|
78
|
+
"""
|
|
79
|
+
Converts the settings object to its dictionary representation.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
_ContinueWithAuthParametersHandlers: The dictionary representation suitable for internal use.
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
return _ContinueWithAuthParametersHandlers(
|
|
86
|
+
response=self.response,
|
|
87
|
+
username=self.username,
|
|
88
|
+
password=self.password,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
async def _build_kwargs_from_handlers_func(
|
|
93
|
+
self: "DevToolsTarget",
|
|
94
|
+
handlers: Mapping[str, Optional[ParameterHandler]],
|
|
95
|
+
event: Any
|
|
96
|
+
) -> kwargs_type:
|
|
97
|
+
"""
|
|
98
|
+
Asynchronously builds keyword arguments for a CDP command by executing parameter handlers.
|
|
99
|
+
|
|
100
|
+
This function iterates through a mapping of parameter handlers, starting each handler
|
|
101
|
+
in a new Trio task. It waits for all handlers to complete before returning the
|
|
102
|
+
aggregated keyword arguments.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
self (DevToolsTarget): the DevToolsTarget instance.
|
|
106
|
+
handlers (Mapping[str, Optional[ParameterHandler]]): A dictionary where keys are parameter names
|
|
107
|
+
and values are `ParameterHandler` objects or None.
|
|
108
|
+
event (Any): The CDP event object that triggered the action, providing context for handlers.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
kwargs_type: A dictionary of keyword arguments ready to be used with a CDP command.
|
|
112
|
+
|
|
113
|
+
Raises:
|
|
114
|
+
BaseException: If any error occurs during the execution of parameter handlers or the process.
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
await self.log(level="INFO", message=f"Started to build kwargs for '{event}'")
|
|
118
|
+
|
|
119
|
+
try:
|
|
120
|
+
kwargs = {"request_id": event.request_id}
|
|
121
|
+
|
|
122
|
+
kwargs_ready_events: list[trio.Event] = []
|
|
123
|
+
|
|
124
|
+
for handler_name, handler_settings in handlers.items():
|
|
125
|
+
if handler_settings is not None:
|
|
126
|
+
kwargs_ready_event = trio.Event()
|
|
127
|
+
kwargs_ready_events.append(kwargs_ready_event)
|
|
128
|
+
|
|
129
|
+
self._nursery_object.start_soon(
|
|
130
|
+
handler_settings["func"],
|
|
131
|
+
self,
|
|
132
|
+
kwargs_ready_event,
|
|
133
|
+
handler_settings["instances"],
|
|
134
|
+
event,
|
|
135
|
+
kwargs
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
for kwargs_ready_event in kwargs_ready_events:
|
|
139
|
+
await kwargs_ready_event.wait()
|
|
140
|
+
|
|
141
|
+
return kwargs
|
|
142
|
+
except* cdp_end_exceptions as error:
|
|
143
|
+
raise error
|
|
144
|
+
except* BaseException as error:
|
|
145
|
+
await self.log_error(error=error)
|
|
146
|
+
raise error
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class _ContinueWithAuth(TypedDict):
|
|
150
|
+
"""
|
|
151
|
+
Internal TypedDict for the 'continueWithAuth' action configuration.
|
|
152
|
+
|
|
153
|
+
Attributes:
|
|
154
|
+
kwargs_func (build_kwargs_from_handlers_func_type): Function to build keyword arguments for the `continueWithAuth` CDP command.
|
|
155
|
+
response_handle_func (response_handle_func_type): A function to process the response from the CDP command.
|
|
156
|
+
parameters_handlers (_ContinueWithAuthParametersHandlers): Handlers for authentication parameters.
|
|
157
|
+
"""
|
|
158
|
+
|
|
159
|
+
kwargs_func: build_kwargs_from_handlers_func_type
|
|
160
|
+
response_handle_func: response_handle_func_type
|
|
161
|
+
parameters_handlers: _ContinueWithAuthParametersHandlers
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@dataclass
|
|
165
|
+
class ContinueWithAuthSettings(AbstractActionSettings):
|
|
166
|
+
"""
|
|
167
|
+
Settings for continuing a request that requires authentication using the `fetch.continueWithAuth` CDP command.
|
|
168
|
+
|
|
169
|
+
Attributes:
|
|
170
|
+
parameters_handlers (ContinueWithAuthParameterHandlersSettings): Settings for the handlers that provide authentication credentials.
|
|
171
|
+
response_handle_func (response_handle_func_type): An optional awaitable function to process the response from the `fetch.continueWithAuth` CDP command. Defaults to None.
|
|
172
|
+
"""
|
|
173
|
+
|
|
174
|
+
parameters_handlers: ContinueWithAuthParameterHandlersSettings
|
|
175
|
+
response_handle_func: response_handle_func_type = None
|
|
176
|
+
|
|
177
|
+
@property
|
|
178
|
+
def kwargs_func(self) -> build_kwargs_from_handlers_func_type:
|
|
179
|
+
"""
|
|
180
|
+
Returns the function used to build keyword arguments for the `continueWithAuth` command.
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
build_kwargs_from_handlers_func_type: The internal function `_build_kwargs_from_handlers_func`.
|
|
184
|
+
"""
|
|
185
|
+
|
|
186
|
+
return _build_kwargs_from_handlers_func
|
|
187
|
+
|
|
188
|
+
def to_dict(self) -> _ContinueWithAuth:
|
|
189
|
+
"""
|
|
190
|
+
Converts the settings object to its dictionary representation.
|
|
191
|
+
|
|
192
|
+
Returns:
|
|
193
|
+
_ContinueWithAuth: The dictionary representation suitable for internal use.
|
|
194
|
+
"""
|
|
195
|
+
|
|
196
|
+
return _ContinueWithAuth(
|
|
197
|
+
kwargs_func=self.kwargs_func,
|
|
198
|
+
response_handle_func=self.response_handle_func,
|
|
199
|
+
parameters_handlers=self.parameters_handlers.to_dict(),
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class _AuthRequiredActions(TypedDict):
|
|
204
|
+
"""
|
|
205
|
+
Internal TypedDict mapping action names for AuthRequired event to their configurations.
|
|
206
|
+
|
|
207
|
+
Attributes:
|
|
208
|
+
continue_with_auth (Optional[_ContinueWithAuth]): Configuration for the 'continueWithAuth' action.
|
|
209
|
+
"""
|
|
210
|
+
|
|
211
|
+
continue_with_auth: Optional[_ContinueWithAuth]
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
@dataclass
|
|
215
|
+
class AuthRequiredActionsSettings(AbstractEventActionsSettings):
|
|
216
|
+
"""
|
|
217
|
+
Container for configurations of possible actions to take when authentication is required.
|
|
218
|
+
|
|
219
|
+
Attributes:
|
|
220
|
+
continue_with_auth (Optional[ContinueWithAuthSettings]): Settings for handling the authentication challenge using `fetch.continueWithAuth`. Defaults to None.
|
|
221
|
+
"""
|
|
222
|
+
|
|
223
|
+
continue_with_auth: Optional[ContinueWithAuthSettings] = None
|
|
224
|
+
|
|
225
|
+
def to_dict(self) -> _AuthRequiredActions:
|
|
226
|
+
"""
|
|
227
|
+
Converts the settings object to its dictionary representation.
|
|
228
|
+
|
|
229
|
+
Returns:
|
|
230
|
+
_AuthRequiredActions: The dictionary representation suitable for internal use.
|
|
231
|
+
"""
|
|
232
|
+
|
|
233
|
+
return _AuthRequiredActions(
|
|
234
|
+
continue_with_auth=self.continue_with_auth.to_dict()
|
|
235
|
+
if self.continue_with_auth is not None
|
|
236
|
+
else None,
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
class _AuthRequiredActionsHandler(AbstractEventActionsHandler):
|
|
241
|
+
"""
|
|
242
|
+
Internal TypedDict for the actions handler configuration for the 'AuthRequired' event.
|
|
243
|
+
|
|
244
|
+
Attributes:
|
|
245
|
+
choose_action_func (auth_required_choose_action_func_type): A function that determines which actions (by name) should be executed for a given 'AuthRequired' event.
|
|
246
|
+
actions (_AuthRequiredActions): A dictionary mapping action names to their full configurations.
|
|
247
|
+
"""
|
|
248
|
+
|
|
249
|
+
choose_action_func: "auth_required_choose_action_func_type"
|
|
250
|
+
actions: _AuthRequiredActions
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
@dataclass
|
|
254
|
+
class AuthRequiredActionsHandlerSettings(AbstractEventActionsHandlerSettings):
|
|
255
|
+
"""
|
|
256
|
+
Settings for handling the 'fetch.AuthRequired' event by choosing and executing specific actions.
|
|
257
|
+
|
|
258
|
+
Attributes:
|
|
259
|
+
choose_action_func (auth_required_choose_action_func_type): A function that takes the DevTools instance and the event object and returns a list of action names (Literals) to execute. Defaults to `auth_required_choose_func`.
|
|
260
|
+
actions (Optional[AuthRequiredActionsSettings]): Container for the configuration of the available actions. Defaults to None.
|
|
261
|
+
"""
|
|
262
|
+
|
|
263
|
+
choose_action_func: "auth_required_choose_action_func_type" = auth_required_choose_func
|
|
264
|
+
actions: Optional[AuthRequiredActionsSettings] = None
|
|
265
|
+
|
|
266
|
+
@property
|
|
267
|
+
def kwargs_func(self) -> build_kwargs_from_handlers_func_type:
|
|
268
|
+
"""
|
|
269
|
+
Returns the function used to build keyword arguments for the actions.
|
|
270
|
+
|
|
271
|
+
Returns:
|
|
272
|
+
build_kwargs_from_handlers_func_type: The internal function `_build_kwargs_from_handlers_func`.
|
|
273
|
+
"""
|
|
274
|
+
|
|
275
|
+
return _build_kwargs_from_handlers_func
|
|
276
|
+
|
|
277
|
+
def to_dict(self) -> _AuthRequiredActionsHandler:
|
|
278
|
+
"""
|
|
279
|
+
Converts the settings object to its dictionary representation.
|
|
280
|
+
|
|
281
|
+
Returns:
|
|
282
|
+
_AuthRequiredActionsHandler: The dictionary representation suitable for internal use.
|
|
283
|
+
"""
|
|
284
|
+
|
|
285
|
+
return _AuthRequiredActionsHandler(
|
|
286
|
+
choose_action_func=self.choose_action_func,
|
|
287
|
+
actions=self.actions.to_dict()
|
|
288
|
+
if self.actions is not None
|
|
289
|
+
else AuthRequiredActionsSettings().to_dict(),
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
class _AuthRequired(AbstractEvent):
|
|
294
|
+
"""
|
|
295
|
+
Internal TypedDict representing the complete configuration for an 'AuthRequired' event listener.
|
|
296
|
+
|
|
297
|
+
This structure extends `AbstractEvent` with specifics for the Fetch.AuthRequired domain event.
|
|
298
|
+
|
|
299
|
+
Attributes:
|
|
300
|
+
class_to_use_path (str): Path to the CDP event class ("fetch.AuthRequired").
|
|
301
|
+
listen_buffer_size (int): Buffer size for the listener channel.
|
|
302
|
+
handle_function (handle_auth_required_func_type): The main handler function for the event (_handle_auth_required).
|
|
303
|
+
actions_handler (_AuthRequiredActionsHandler): Callbacks and configurations for choosing and executing actions based on the event.
|
|
304
|
+
on_error_func (on_error_func_type): Function to call on error during event handling.
|
|
305
|
+
"""
|
|
306
|
+
|
|
307
|
+
class_to_use_path: str
|
|
308
|
+
listen_buffer_size: int
|
|
309
|
+
handle_function: "handle_auth_required_func_type"
|
|
310
|
+
actions_handler: _AuthRequiredActionsHandler
|
|
311
|
+
on_error_func: on_error_func_type
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
async def _handle_auth_required(self: "DevToolsTarget", handler_settings: _AuthRequired, event: Any):
|
|
315
|
+
"""
|
|
316
|
+
Handles the 'fetch.AuthRequired' CDP event.
|
|
317
|
+
|
|
318
|
+
This function determines which actions to take based on the `choose_action_func`
|
|
319
|
+
defined in the handler settings, builds the necessary keyword arguments for the
|
|
320
|
+
chosen actions using their respective parameter handlers, executes the CDP commands,
|
|
321
|
+
and processes their responses.
|
|
322
|
+
|
|
323
|
+
Args:
|
|
324
|
+
self (DevToolsTarget): The DevToolsTarget instance.
|
|
325
|
+
handler_settings (_AuthRequired): The configuration settings for handling the 'AuthRequired' event.
|
|
326
|
+
event (Any): The 'AuthRequired' event object received from the CDP.
|
|
327
|
+
|
|
328
|
+
Raises:
|
|
329
|
+
BaseException: If a critical error occurs during the event handling process.
|
|
330
|
+
"""
|
|
331
|
+
|
|
332
|
+
await self.log(level="INFO", message=f"Started to handle for '{event}'")
|
|
333
|
+
|
|
334
|
+
try:
|
|
335
|
+
chosen_actions_func_names = handler_settings["actions_handler"]["choose_action_func"](self, event)
|
|
336
|
+
await self.log(level="INFO", message=f"Chosen actions: '{chosen_actions_func_names}'")
|
|
337
|
+
|
|
338
|
+
for action_func_name in chosen_actions_func_names:
|
|
339
|
+
chosen_func = handler_settings["actions_handler"]["actions"][action_func_name]
|
|
340
|
+
kwargs = await chosen_func["kwargs_func"](self, chosen_func["parameters_handlers"], event)
|
|
341
|
+
await self.log(level="INFO", message=f"Kwargs for '{action_func_name}': '{kwargs}'")
|
|
342
|
+
response_handle_func = chosen_func["response_handle_func"]
|
|
343
|
+
|
|
344
|
+
try:
|
|
345
|
+
response = await execute_cdp_command(
|
|
346
|
+
self,
|
|
347
|
+
"raise",
|
|
348
|
+
await self.get_devtools_object(f"fetch.{action_func_name}"),
|
|
349
|
+
**kwargs
|
|
350
|
+
)
|
|
351
|
+
await self.log(
|
|
352
|
+
level="AuthRequired",
|
|
353
|
+
message=f"Function '{action_func_name}' response: '{response}'"
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
if response_handle_func is not None:
|
|
357
|
+
self._nursery_object.start_soon(response_handle_func, self, response)
|
|
358
|
+
except* cdp_end_exceptions:
|
|
359
|
+
pass
|
|
360
|
+
except* BaseException as error:
|
|
361
|
+
await self.log_error(error=error)
|
|
362
|
+
|
|
363
|
+
on_error = handler_settings["on_error_func"]
|
|
364
|
+
|
|
365
|
+
if on_error is not None:
|
|
366
|
+
on_error(self, event, error)
|
|
367
|
+
except* cdp_end_exceptions as error:
|
|
368
|
+
raise error
|
|
369
|
+
except* BaseException as error:
|
|
370
|
+
await self.log_error(error=error)
|
|
371
|
+
raise error
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
@dataclass
|
|
375
|
+
class AuthRequiredSettings(AbstractEventSettings):
|
|
376
|
+
"""
|
|
377
|
+
Settings for handling the 'fetch.AuthRequired' event.
|
|
378
|
+
|
|
379
|
+
This dataclass allows configuring the listener for the 'AuthRequired' CDP event,
|
|
380
|
+
including buffer size, the actions to take, and error handling.
|
|
381
|
+
|
|
382
|
+
Attributes:
|
|
383
|
+
actions_handler (AuthRequiredActionsHandlerSettings): Configuration for the event's actions handler, determining which action to take (e.g., continueWithAuth) and how to build its parameters.
|
|
384
|
+
listen_buffer_size (int): The buffer size for the event listener channel. Defaults to 10.
|
|
385
|
+
on_error_func (on_error_func_type): An optional function to call if an error occurs during event handling. Defaults to None.
|
|
386
|
+
"""
|
|
387
|
+
|
|
388
|
+
actions_handler: AuthRequiredActionsHandlerSettings
|
|
389
|
+
listen_buffer_size: int = 10
|
|
390
|
+
on_error_func: on_error_func_type = None
|
|
391
|
+
|
|
392
|
+
@property
|
|
393
|
+
def handle_function(self) -> "handle_auth_required_func_type":
|
|
394
|
+
"""
|
|
395
|
+
Returns the main handler function for the 'fetch.AuthRequired' event.
|
|
396
|
+
|
|
397
|
+
Returns:
|
|
398
|
+
handle_auth_required_func_type: The internal function `_handle_auth_required`.
|
|
399
|
+
"""
|
|
400
|
+
|
|
401
|
+
return _handle_auth_required
|
|
402
|
+
|
|
403
|
+
@property
|
|
404
|
+
def class_to_use_path(self) -> str:
|
|
405
|
+
"""
|
|
406
|
+
Returns the path to the CDP event class for 'fetch.AuthRequired'.
|
|
407
|
+
|
|
408
|
+
Returns:
|
|
409
|
+
str: The string "fetch.AuthRequired".
|
|
410
|
+
"""
|
|
411
|
+
|
|
412
|
+
return "fetch.AuthRequired"
|
|
413
|
+
|
|
414
|
+
def to_dict(self) -> _AuthRequired:
|
|
415
|
+
"""
|
|
416
|
+
Converts the settings object to its dictionary representation.
|
|
417
|
+
|
|
418
|
+
Returns:
|
|
419
|
+
_AuthRequired: The dictionary representation suitable for internal use.
|
|
420
|
+
"""
|
|
421
|
+
|
|
422
|
+
return _AuthRequired(
|
|
423
|
+
class_to_use_path=self.class_to_use_path,
|
|
424
|
+
listen_buffer_size=self.listen_buffer_size,
|
|
425
|
+
handle_function=self.handle_function,
|
|
426
|
+
actions_handler=self.actions_handler.to_dict(),
|
|
427
|
+
on_error_func=self.on_error_func,
|
|
428
|
+
)
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
class _ContinueResponseParametersHandlers(TypedDict):
|
|
432
|
+
"""
|
|
433
|
+
Internal TypedDict for handlers related to the 'continueResponse' action parameters.
|
|
434
|
+
|
|
435
|
+
Attributes:
|
|
436
|
+
response_code (Optional[ParameterHandler]): Handler for the HTTP response code.
|
|
437
|
+
response_phrase (Optional[ParameterHandler]): Handler for the HTTP response phrase.
|
|
438
|
+
response_headers (Optional[ParameterHandler]): Handler for the response headers.
|
|
439
|
+
binary_response_headers (Optional[ParameterHandler]): Handler for binary response headers (base64 encoded).
|
|
440
|
+
"""
|
|
441
|
+
|
|
442
|
+
response_code: Optional[ParameterHandler]
|
|
443
|
+
response_phrase: Optional[ParameterHandler]
|
|
444
|
+
response_headers: Optional[ParameterHandler]
|
|
445
|
+
binary_response_headers: Optional[ParameterHandler]
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
class _ContinueResponseAction(AbstractAction):
|
|
449
|
+
"""
|
|
450
|
+
Internal TypedDict for the 'continueResponse' action configuration within RequestPaused.
|
|
451
|
+
|
|
452
|
+
Attributes:
|
|
453
|
+
kwargs_func (build_kwargs_from_handlers_func_type): Function to build keyword arguments for the `continueResponse` CDP command.
|
|
454
|
+
response_handle_func (response_handle_func_type): A function to process the response from the CDP command.
|
|
455
|
+
parameters_handlers (_ContinueResponseParametersHandlers): Handlers for modifying response parameters.
|
|
456
|
+
"""
|
|
457
|
+
|
|
458
|
+
kwargs_func: build_kwargs_from_handlers_func_type
|
|
459
|
+
response_handle_func: response_handle_func_type
|
|
460
|
+
parameters_handlers: _ContinueResponseParametersHandlers
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
class _FulfillRequestParametersHandlers(TypedDict):
|
|
464
|
+
"""
|
|
465
|
+
Internal TypedDict for handlers related to the 'fulfillRequest' action parameters.
|
|
466
|
+
|
|
467
|
+
Attributes:
|
|
468
|
+
response_code (ParameterHandler): Required handler for the HTTP response code (e.g., 200).
|
|
469
|
+
response_headers (Optional[ParameterHandler]): Handler for the response headers.
|
|
470
|
+
binary_response_headers (Optional[ParameterHandler]): Handler for binary response headers (base64 encoded).
|
|
471
|
+
body (Optional[ParameterHandler]): Handler for the response body (base64 encoded string).
|
|
472
|
+
response_phrase (Optional[ParameterHandler]): Handler for the HTTP response phrase (e.g., "OK").
|
|
473
|
+
"""
|
|
474
|
+
|
|
475
|
+
response_code: ParameterHandler
|
|
476
|
+
response_headers: Optional[ParameterHandler]
|
|
477
|
+
binary_response_headers: Optional[ParameterHandler]
|
|
478
|
+
body: Optional[ParameterHandler]
|
|
479
|
+
response_phrase: Optional[ParameterHandler]
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
class _FulfillRequestAction(AbstractAction):
|
|
483
|
+
"""
|
|
484
|
+
Internal TypedDict for the 'fulfillRequest' action configuration within RequestPaused.
|
|
485
|
+
|
|
486
|
+
Attributes:
|
|
487
|
+
kwargs_func (build_kwargs_from_handlers_func_type): Function to build keyword arguments for the `fulfillRequest` CDP command.
|
|
488
|
+
response_handle_func (response_handle_func_type): A function to process the response from the CDP command.
|
|
489
|
+
parameters_handlers (_FulfillRequestParametersHandlers): Handlers for mock response parameters.
|
|
490
|
+
"""
|
|
491
|
+
|
|
492
|
+
kwargs_func: build_kwargs_from_handlers_func_type
|
|
493
|
+
response_handle_func: response_handle_func_type
|
|
494
|
+
parameters_handlers: _FulfillRequestParametersHandlers
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
class _FailRequestParametersHandlers(TypedDict):
|
|
498
|
+
"""
|
|
499
|
+
Internal TypedDict for handlers related to the 'failRequest' action parameters.
|
|
500
|
+
|
|
501
|
+
Attributes:
|
|
502
|
+
error_reason (ParameterHandler): Required handler for providing the network error reason (a string from Network.ErrorReason enum).
|
|
503
|
+
"""
|
|
504
|
+
|
|
505
|
+
error_reason: ParameterHandler
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
class _FailRequestAction(AbstractAction):
|
|
509
|
+
"""
|
|
510
|
+
Internal TypedDict for the 'failRequest' action configuration within RequestPaused.
|
|
511
|
+
|
|
512
|
+
Attributes:
|
|
513
|
+
kwargs_func (build_kwargs_from_handlers_func_type): Function to build keyword arguments for the `failRequest` CDP command.
|
|
514
|
+
response_handle_func (response_handle_func_type): A function to process the response from the CDP command.
|
|
515
|
+
parameters_handlers (_FailRequestParametersHandlers): Handlers for the error reason parameter.
|
|
516
|
+
"""
|
|
517
|
+
|
|
518
|
+
kwargs_func: build_kwargs_from_handlers_func_type
|
|
519
|
+
response_handle_func: response_handle_func_type
|
|
520
|
+
parameters_handlers: _FailRequestParametersHandlers
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
class _ContinueRequestParametersHandlers(TypedDict):
|
|
524
|
+
"""
|
|
525
|
+
Internal TypedDict for handlers related to the 'continueRequest' action parameters.
|
|
526
|
+
|
|
527
|
+
Attributes:
|
|
528
|
+
url (Optional[ParameterHandler]): Handler for modifying the request URL.
|
|
529
|
+
method (Optional[ParameterHandler]): Handler for modifying the HTTP method.
|
|
530
|
+
post_data (Optional[ParameterHandler]): Handler for modifying the request's post data (base64 encoded string).
|
|
531
|
+
headers (Optional[ParameterHandler]): Handler for modifying the request headers.
|
|
532
|
+
intercept_response (Optional[ParameterHandler]): Handler for setting response interception behavior for this request.
|
|
533
|
+
"""
|
|
534
|
+
|
|
535
|
+
url: Optional[ParameterHandler]
|
|
536
|
+
method: Optional[ParameterHandler]
|
|
537
|
+
post_data: Optional[ParameterHandler]
|
|
538
|
+
headers: Optional[ParameterHandler]
|
|
539
|
+
intercept_response: Optional[ParameterHandler]
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
class _ContinueRequestAction(AbstractAction):
|
|
543
|
+
"""
|
|
544
|
+
Internal TypedDict for the 'continueRequest' action configuration within RequestPaused.
|
|
545
|
+
|
|
546
|
+
Attributes:
|
|
547
|
+
kwargs_func (build_kwargs_from_handlers_func_type): Function to build keyword arguments for the `continueRequest` CDP command.
|
|
548
|
+
response_handle_func (response_handle_func_type): A function to process the response from the CDP command.
|
|
549
|
+
parameters_handlers (_ContinueRequestParametersHandlers): Handlers for modifying request parameters.
|
|
550
|
+
"""
|
|
551
|
+
|
|
552
|
+
kwargs_func: build_kwargs_from_handlers_func_type
|
|
553
|
+
response_handle_func: response_handle_func_type
|
|
554
|
+
parameters_handlers: _ContinueRequestParametersHandlers
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
class _RequestPausedActions(TypedDict):
|
|
558
|
+
"""
|
|
559
|
+
Internal TypedDict mapping action names for RequestPaused event to their configurations.
|
|
560
|
+
|
|
561
|
+
Attributes:
|
|
562
|
+
continue_request (Optional[_ContinueRequestAction]): Configuration for the 'continueRequest' action.
|
|
563
|
+
fail_request (Optional[_FailRequestAction]): Configuration for the 'failRequest' action.
|
|
564
|
+
fulfill_request (Optional[_FulfillRequestAction]): Configuration for the 'fulfillRequest' action.
|
|
565
|
+
continue_response (Optional[_ContinueResponseAction]): Configuration for the 'continueResponse' action.
|
|
566
|
+
"""
|
|
567
|
+
|
|
568
|
+
continue_request: Optional[_ContinueRequestAction]
|
|
569
|
+
fail_request: Optional[_FailRequestAction]
|
|
570
|
+
fulfill_request: Optional[_FulfillRequestAction]
|
|
571
|
+
continue_response: Optional[_ContinueResponseAction]
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
class _RequestPausedActionsHandler(AbstractEventActionsHandler):
|
|
575
|
+
"""
|
|
576
|
+
Internal TypedDict for the actions handler configuration for the 'RequestPaused' event.
|
|
577
|
+
|
|
578
|
+
Attributes:
|
|
579
|
+
choose_action_func (request_paused_choose_action_func_type): A function that determines which actions (by name) should be executed for a given 'RequestPaused' event.
|
|
580
|
+
actions (_RequestPausedActions): A dictionary mapping action names to their full configurations.
|
|
581
|
+
"""
|
|
582
|
+
|
|
583
|
+
choose_action_func: "request_paused_choose_action_func_type"
|
|
584
|
+
actions: _RequestPausedActions
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
class _RequestPaused(AbstractEvent):
|
|
588
|
+
"""
|
|
589
|
+
Internal TypedDict representing the complete configuration for a 'RequestPaused' event listener.
|
|
590
|
+
|
|
591
|
+
This structure extends `AbstractEvent` with specifics for the Fetch.RequestPaused domain event.
|
|
592
|
+
|
|
593
|
+
Attributes:
|
|
594
|
+
class_to_use_path (str): Path to the CDP event class ("fetch.RequestPaused").
|
|
595
|
+
listen_buffer_size (int): Buffer size for the listener channel.
|
|
596
|
+
handle_function (handle_request_paused_func_type): The main handler function for the event (_handle_request_paused).
|
|
597
|
+
actions_handler (_RequestPausedActionsHandler): Callbacks and configurations for choosing and executing actions based on the event.
|
|
598
|
+
on_error_func (on_error_func_type): Function to call on error during event handling.
|
|
599
|
+
"""
|
|
600
|
+
|
|
601
|
+
class_to_use_path: str
|
|
602
|
+
listen_buffer_size: int
|
|
603
|
+
handle_function: "handle_request_paused_func_type"
|
|
604
|
+
actions_handler: _RequestPausedActionsHandler
|
|
605
|
+
on_error_func: on_error_func_type
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
async def _handle_request_paused(self: "DevToolsTarget", handler_settings: _RequestPaused, event: Any):
|
|
609
|
+
"""
|
|
610
|
+
Handles the 'fetch.RequestPaused' CDP event.
|
|
611
|
+
|
|
612
|
+
This function determines which actions to take based on the `choose_action_func`
|
|
613
|
+
defined in the handler settings, builds the necessary keyword arguments for the
|
|
614
|
+
chosen actions using their respective parameter handlers, executes the CDP commands,
|
|
615
|
+
and processes their responses.
|
|
616
|
+
|
|
617
|
+
Args:
|
|
618
|
+
self (DevToolsTarget): The DevToolsTarget instance.
|
|
619
|
+
handler_settings (_RequestPaused): The configuration settings for handling the 'RequestPaused' event.
|
|
620
|
+
event (Any): The 'RequestPaused' event object received from the CDP.
|
|
621
|
+
|
|
622
|
+
Raises:
|
|
623
|
+
BaseException: If a critical error occurs during the event handling process.
|
|
624
|
+
"""
|
|
625
|
+
|
|
626
|
+
await self.log(level="INFO", message=f"Started to handle for '{event}'")
|
|
627
|
+
|
|
628
|
+
try:
|
|
629
|
+
chosen_actions_func_names = handler_settings["actions_handler"]["choose_action_func"](self, event)
|
|
630
|
+
await self.log(level="INFO", message=f"Chosen actions: '{chosen_actions_func_names}'")
|
|
631
|
+
|
|
632
|
+
for action_func_name in chosen_actions_func_names:
|
|
633
|
+
chosen_action_func = handler_settings["actions_handler"]["actions"][action_func_name]
|
|
634
|
+
|
|
635
|
+
kwargs = await chosen_action_func["kwargs_func"](self, chosen_action_func["parameters_handlers"], event)
|
|
636
|
+
await self.log(level="INFO", message=f"Kwargs for '{action_func_name}': '{kwargs}'")
|
|
637
|
+
|
|
638
|
+
response_handle_func = chosen_action_func["response_handle_func"]
|
|
639
|
+
|
|
640
|
+
try:
|
|
641
|
+
response = await execute_cdp_command(
|
|
642
|
+
self,
|
|
643
|
+
"raise",
|
|
644
|
+
await self.get_devtools_object(f"fetch.{action_func_name}"),
|
|
645
|
+
**kwargs
|
|
646
|
+
)
|
|
647
|
+
await self.log(
|
|
648
|
+
level="RequestPaused",
|
|
649
|
+
message=f"Function '{action_func_name}' response: '{response}'"
|
|
650
|
+
)
|
|
651
|
+
|
|
652
|
+
if response_handle_func is not None:
|
|
653
|
+
self._nursery_object.start_soon(response_handle_func, self, response)
|
|
654
|
+
except* cdp_end_exceptions:
|
|
655
|
+
pass
|
|
656
|
+
except* BaseException as error:
|
|
657
|
+
await self.log_error(error=error)
|
|
658
|
+
|
|
659
|
+
on_error = handler_settings["on_error_func"]
|
|
660
|
+
|
|
661
|
+
if on_error is not None:
|
|
662
|
+
on_error(self, event, error)
|
|
663
|
+
except* cdp_end_exceptions as error:
|
|
664
|
+
raise error
|
|
665
|
+
except* BaseException as error:
|
|
666
|
+
await self.log_error(error=error)
|
|
667
|
+
raise error
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
@dataclass
|
|
671
|
+
class ContinueResponseHandlersSettings(AbstractActionParametersHandlersSettings):
|
|
672
|
+
"""
|
|
673
|
+
Configuration for handlers that modify a response before it continues using `fetch.continueResponse`.
|
|
674
|
+
|
|
675
|
+
These handlers provide parameter values for the `fetch.continueResponse` CDP command.
|
|
676
|
+
|
|
677
|
+
Attributes:
|
|
678
|
+
response_code (Optional[ParameterHandler]): Handler for the HTTP response code. Defaults to None.
|
|
679
|
+
response_phrase (Optional[ParameterHandler]): Handler for the HTTP response phrase. Defaults to None.
|
|
680
|
+
response_headers (Optional[ParameterHandler]): Handler for the response headers. Defaults to None.
|
|
681
|
+
binary_response_headers (Optional[ParameterHandler]): Handler for binary response headers (base64 encoded). Defaults to None.
|
|
682
|
+
"""
|
|
683
|
+
|
|
684
|
+
response_code: Optional[ParameterHandler] = None
|
|
685
|
+
response_phrase: Optional[ParameterHandler] = None
|
|
686
|
+
response_headers: Optional[ParameterHandler] = None
|
|
687
|
+
binary_response_headers: Optional[ParameterHandler] = None
|
|
688
|
+
|
|
689
|
+
def to_dict(self) -> _ContinueResponseParametersHandlers:
|
|
690
|
+
"""
|
|
691
|
+
Converts the settings object to its dictionary representation.
|
|
692
|
+
|
|
693
|
+
Returns:
|
|
694
|
+
_ContinueResponseParametersHandlers: The dictionary representation suitable for internal use.
|
|
695
|
+
"""
|
|
696
|
+
|
|
697
|
+
return _ContinueResponseParametersHandlers(
|
|
698
|
+
response_code=self.response_code,
|
|
699
|
+
response_phrase=self.response_phrase,
|
|
700
|
+
response_headers=self.response_headers,
|
|
701
|
+
binary_response_headers=self.binary_response_headers
|
|
702
|
+
)
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
@dataclass
|
|
706
|
+
class ContinueResponseSettings(AbstractActionSettings):
|
|
707
|
+
"""
|
|
708
|
+
Settings for the 'continueResponse' action for a paused request (from RequestPaused event).
|
|
709
|
+
|
|
710
|
+
This action is used to modify and continue a request *after* the response has been received but before it is processed by the browser.
|
|
711
|
+
|
|
712
|
+
Attributes:
|
|
713
|
+
response_handle_func (response_handle_func_type): An optional awaitable function to process the response from the `fetch.continueResponse` CDP command. Defaults to None.
|
|
714
|
+
parameters_handlers (Optional[ContinueResponseHandlersSettings]): Configuration for the response parameter handlers that provide modified response details. Defaults to None.
|
|
715
|
+
"""
|
|
716
|
+
|
|
717
|
+
response_handle_func: response_handle_func_type = None
|
|
718
|
+
parameters_handlers: Optional[ContinueResponseHandlersSettings] = None
|
|
719
|
+
|
|
720
|
+
@property
|
|
721
|
+
def kwargs_func(self) -> build_kwargs_from_handlers_func_type:
|
|
722
|
+
"""
|
|
723
|
+
Returns the function used to build keyword arguments for the `continueResponse` command.
|
|
724
|
+
|
|
725
|
+
Returns:
|
|
726
|
+
build_kwargs_from_handlers_func_type: The internal function `_build_kwargs_from_handlers_func`.
|
|
727
|
+
"""
|
|
728
|
+
|
|
729
|
+
return _build_kwargs_from_handlers_func
|
|
730
|
+
|
|
731
|
+
def to_dict(self) -> _ContinueResponseAction:
|
|
732
|
+
"""
|
|
733
|
+
Converts the settings object to its dictionary representation.
|
|
734
|
+
|
|
735
|
+
Returns:
|
|
736
|
+
_ContinueResponseAction: The dictionary representation suitable for internal use.
|
|
737
|
+
"""
|
|
738
|
+
|
|
739
|
+
return _ContinueResponseAction(
|
|
740
|
+
kwargs_func=self.kwargs_func,
|
|
741
|
+
response_handle_func=self.response_handle_func,
|
|
742
|
+
parameters_handlers=self.parameters_handlers.to_dict()
|
|
743
|
+
if self.parameters_handlers is not None
|
|
744
|
+
else ContinueResponseHandlersSettings().to_dict(),
|
|
745
|
+
)
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
@dataclass
|
|
749
|
+
class FulfillRequestHandlersSettings(AbstractActionParametersHandlersSettings):
|
|
750
|
+
"""
|
|
751
|
+
Configuration for handlers that provide a mock response to a request using `fetch.fulfillRequest`.
|
|
752
|
+
|
|
753
|
+
These handlers provide parameter values for the `fetch.fulfillRequest` CDP command.
|
|
754
|
+
|
|
755
|
+
Attributes:
|
|
756
|
+
response_code (ParameterHandler): Required handler for the HTTP response code (e.g., 200).
|
|
757
|
+
response_headers (Optional[ParameterHandler]): Handler for the response headers. Defaults to None.
|
|
758
|
+
binary_response_headers (Optional[ParameterHandler]): Handler for binary response headers (base64 encoded). Defaults to None.
|
|
759
|
+
body (Optional[ParameterHandler]): Handler for the response body (base64 encoded string). Defaults to None.
|
|
760
|
+
response_phrase (Optional[ParameterHandler]): Handler for the HTTP response phrase (e.g., "OK"). Defaults to None.
|
|
761
|
+
"""
|
|
762
|
+
|
|
763
|
+
response_code: ParameterHandler
|
|
764
|
+
response_headers: Optional[ParameterHandler] = None
|
|
765
|
+
binary_response_headers: Optional[ParameterHandler] = None
|
|
766
|
+
body: Optional[ParameterHandler] = None
|
|
767
|
+
response_phrase: Optional[ParameterHandler] = None
|
|
768
|
+
|
|
769
|
+
def to_dict(self) -> _FulfillRequestParametersHandlers:
|
|
770
|
+
"""
|
|
771
|
+
Converts the settings object to its dictionary representation.
|
|
772
|
+
|
|
773
|
+
Returns:
|
|
774
|
+
_FulfillRequestParametersHandlers: The dictionary representation suitable for internal use.
|
|
775
|
+
"""
|
|
776
|
+
|
|
777
|
+
return _FulfillRequestParametersHandlers(
|
|
778
|
+
response_code=self.response_code,
|
|
779
|
+
response_headers=self.response_headers,
|
|
780
|
+
binary_response_headers=self.binary_response_headers,
|
|
781
|
+
body=self.body,
|
|
782
|
+
response_phrase=self.response_phrase,
|
|
783
|
+
)
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
@dataclass
|
|
787
|
+
class FulfillRequestSettings(AbstractActionSettings):
|
|
788
|
+
"""
|
|
789
|
+
Settings for the 'fulfillRequest' action for a paused request (from RequestPaused event).
|
|
790
|
+
|
|
791
|
+
This action is used to provide a completely mock response for a request, preventing the browser from sending it to the network.
|
|
792
|
+
|
|
793
|
+
Attributes:
|
|
794
|
+
parameters_handlers (FulfillRequestHandlersSettings): Configuration for the mock response parameter handlers.
|
|
795
|
+
response_handle_func (response_handle_func_type): An optional awaitable function to process the response from the `fetch.fulfillRequest` CDP command. Defaults to None.
|
|
796
|
+
"""
|
|
797
|
+
|
|
798
|
+
parameters_handlers: FulfillRequestHandlersSettings
|
|
799
|
+
response_handle_func: response_handle_func_type = None
|
|
800
|
+
|
|
801
|
+
@property
|
|
802
|
+
def kwargs_func(self) -> build_kwargs_from_handlers_func_type:
|
|
803
|
+
"""
|
|
804
|
+
Returns the function used to build keyword arguments for the `fulfillRequest` command.
|
|
805
|
+
|
|
806
|
+
Returns:
|
|
807
|
+
build_kwargs_from_handlers_func_type: The internal function `_build_kwargs_from_handlers_func`.
|
|
808
|
+
"""
|
|
809
|
+
|
|
810
|
+
return _build_kwargs_from_handlers_func
|
|
811
|
+
|
|
812
|
+
def to_dict(self) -> _FulfillRequestAction:
|
|
813
|
+
"""
|
|
814
|
+
Converts the settings object to its dictionary representation.
|
|
815
|
+
|
|
816
|
+
Returns:
|
|
817
|
+
_FulfillRequestAction: The dictionary representation suitable for internal use.
|
|
818
|
+
"""
|
|
819
|
+
|
|
820
|
+
return _FulfillRequestAction(
|
|
821
|
+
kwargs_func=self.kwargs_func,
|
|
822
|
+
response_handle_func=self.response_handle_func,
|
|
823
|
+
parameters_handlers=self.parameters_handlers.to_dict(),
|
|
824
|
+
)
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
@dataclass
|
|
828
|
+
class FailRequestHandlersSettings(AbstractActionParametersHandlersSettings):
|
|
829
|
+
"""
|
|
830
|
+
Configuration for handlers that specify the reason for failing a request using `fetch.failRequest`.
|
|
831
|
+
|
|
832
|
+
These handlers provide parameter values for the `fetch.failRequest` CDP command.
|
|
833
|
+
|
|
834
|
+
Attributes:
|
|
835
|
+
error_reason (ParameterHandler): Required handler for providing the network error reason (a string from Network.ErrorReason enum, e.g., "Aborted", "AccessDenied").
|
|
836
|
+
"""
|
|
837
|
+
|
|
838
|
+
error_reason: ParameterHandler
|
|
839
|
+
|
|
840
|
+
def to_dict(self) -> _FailRequestParametersHandlers:
|
|
841
|
+
"""
|
|
842
|
+
Converts the settings object to its dictionary representation.
|
|
843
|
+
|
|
844
|
+
Returns:
|
|
845
|
+
_FailRequestParametersHandlers: The dictionary representation suitable for internal use.
|
|
846
|
+
"""
|
|
847
|
+
|
|
848
|
+
return _FailRequestParametersHandlers(error_reason=self.error_reason)
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
@dataclass
|
|
852
|
+
class FailRequestSettings(AbstractActionSettings):
|
|
853
|
+
"""
|
|
854
|
+
Settings for the 'failRequest' action for a paused request (from RequestPaused event).
|
|
855
|
+
|
|
856
|
+
This action is used to cause the request to fail with a specific network error reason.
|
|
857
|
+
|
|
858
|
+
Attributes:
|
|
859
|
+
parameters_handlers (FailRequestHandlersSettings): Configuration for the error reason handler.
|
|
860
|
+
response_handle_func (response_handle_func_type): An optional awaitable function to process the response from the `fetch.failRequest` CDP command. Defaults to None.
|
|
861
|
+
"""
|
|
862
|
+
|
|
863
|
+
parameters_handlers: FailRequestHandlersSettings
|
|
864
|
+
response_handle_func: response_handle_func_type = None
|
|
865
|
+
|
|
866
|
+
@property
|
|
867
|
+
def kwargs_func(self) -> build_kwargs_from_handlers_func_type:
|
|
868
|
+
"""
|
|
869
|
+
Returns the function used to build keyword arguments for the `failRequest` command.
|
|
870
|
+
|
|
871
|
+
Returns:
|
|
872
|
+
build_kwargs_from_handlers_func_type: The internal function `_build_kwargs_from_handlers_func`.
|
|
873
|
+
"""
|
|
874
|
+
|
|
875
|
+
return _build_kwargs_from_handlers_func
|
|
876
|
+
|
|
877
|
+
def to_dict(self) -> _FailRequestAction:
|
|
878
|
+
"""
|
|
879
|
+
Converts the settings object to its dictionary representation.
|
|
880
|
+
|
|
881
|
+
Returns:
|
|
882
|
+
_FailRequestAction: The dictionary representation suitable for internal use.
|
|
883
|
+
"""
|
|
884
|
+
|
|
885
|
+
return _FailRequestAction(
|
|
886
|
+
kwargs_func=self.kwargs_func,
|
|
887
|
+
response_handle_func=self.response_handle_func,
|
|
888
|
+
parameters_handlers=self.parameters_handlers.to_dict(),
|
|
889
|
+
)
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
@dataclass
|
|
893
|
+
class ContinueRequestHandlersSettings(AbstractActionParametersHandlersSettings):
|
|
894
|
+
"""
|
|
895
|
+
Configuration for handlers that modify a request before it continues using `fetch.continueRequest`.
|
|
896
|
+
|
|
897
|
+
These handlers provide parameter values for the `fetch.continueRequest` CDP command.
|
|
898
|
+
|
|
899
|
+
Attributes:
|
|
900
|
+
url (Optional[ParameterHandler]): Handler for modifying the request URL. Defaults to None.
|
|
901
|
+
method (Optional[ParameterHandler]): Handler for modifying the HTTP method. Defaults to None.
|
|
902
|
+
post_data (Optional[ParameterHandler]): Handler for modifying the request's post data (base64 encoded string). Defaults to None.
|
|
903
|
+
headers (Optional[ParameterHandler]): Handler for modifying the request headers. Defaults to None.
|
|
904
|
+
intercept_response (Optional[ParameterHandler]): Handler for setting response interception behavior for this request. Defaults to None.
|
|
905
|
+
"""
|
|
906
|
+
|
|
907
|
+
url: Optional[ParameterHandler] = None
|
|
908
|
+
method: Optional[ParameterHandler] = None
|
|
909
|
+
post_data: Optional[ParameterHandler] = None
|
|
910
|
+
headers: Optional[ParameterHandler] = None
|
|
911
|
+
intercept_response: Optional[ParameterHandler] = None
|
|
912
|
+
|
|
913
|
+
def to_dict(self) -> _ContinueRequestParametersHandlers:
|
|
914
|
+
"""
|
|
915
|
+
Converts the settings object to its dictionary representation.
|
|
916
|
+
|
|
917
|
+
Returns:
|
|
918
|
+
_ContinueRequestParametersHandlers: The dictionary representation suitable for internal use.
|
|
919
|
+
"""
|
|
920
|
+
|
|
921
|
+
return _ContinueRequestParametersHandlers(
|
|
922
|
+
url=self.url,
|
|
923
|
+
method=self.method,
|
|
924
|
+
post_data=self.post_data,
|
|
925
|
+
headers=self.headers,
|
|
926
|
+
intercept_response=self.intercept_response,
|
|
927
|
+
)
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
@dataclass
|
|
931
|
+
class ContinueRequestSettings(AbstractActionSettings):
|
|
932
|
+
"""
|
|
933
|
+
Settings for the 'continueRequest' action for a paused request (from RequestPaused event).
|
|
934
|
+
|
|
935
|
+
This action is used to allow the request to proceed, optionally after modifying it.
|
|
936
|
+
|
|
937
|
+
Attributes:
|
|
938
|
+
response_handle_func (response_handle_func_type): An optional awaitable function to process the response from the `fetch.continueRequest` CDP command. Defaults to None.
|
|
939
|
+
parameters_handlers (Optional[ContinueRequestHandlersSettings]): Configuration for the request parameter handlers that provide modified request details. Defaults to None.
|
|
940
|
+
"""
|
|
941
|
+
|
|
942
|
+
response_handle_func: response_handle_func_type = None
|
|
943
|
+
parameters_handlers: Optional[ContinueRequestHandlersSettings] = None
|
|
944
|
+
|
|
945
|
+
@property
|
|
946
|
+
def kwargs_func(self) -> build_kwargs_from_handlers_func_type:
|
|
947
|
+
"""
|
|
948
|
+
Returns the function used to build keyword arguments for the `continueRequest` command.
|
|
949
|
+
|
|
950
|
+
Returns:
|
|
951
|
+
build_kwargs_from_handlers_func_type: The internal function `_build_kwargs_from_handlers_func`.
|
|
952
|
+
"""
|
|
953
|
+
|
|
954
|
+
return _build_kwargs_from_handlers_func
|
|
955
|
+
|
|
956
|
+
def to_dict(self) -> _ContinueRequestAction:
|
|
957
|
+
"""
|
|
958
|
+
Converts the settings object to its dictionary representation.
|
|
959
|
+
|
|
960
|
+
Returns:
|
|
961
|
+
_ContinueRequestAction: The dictionary representation suitable for internal use.
|
|
962
|
+
"""
|
|
963
|
+
|
|
964
|
+
return _ContinueRequestAction(
|
|
965
|
+
kwargs_func=self.kwargs_func,
|
|
966
|
+
response_handle_func=self.response_handle_func,
|
|
967
|
+
parameters_handlers=self.parameters_handlers.to_dict()
|
|
968
|
+
if self.parameters_handlers is not None
|
|
969
|
+
else ContinueRequestHandlersSettings().to_dict(),
|
|
970
|
+
)
|
|
971
|
+
|
|
972
|
+
|
|
973
|
+
@dataclass
|
|
974
|
+
class RequestPausedActionsSettings(AbstractEventActionsSettings):
|
|
975
|
+
"""
|
|
976
|
+
Container for configurations of possible actions to take when a request is paused.
|
|
977
|
+
|
|
978
|
+
Attributes:
|
|
979
|
+
continue_request (Optional[ContinueRequestSettings]): Settings for handling the paused request using `fetch.continueRequest`. Defaults to None.
|
|
980
|
+
fail_request (Optional[FailRequestSettings]): Settings for handling the paused request using `fetch.failRequest`. Defaults to None.
|
|
981
|
+
fulfill_request (Optional[FulfillRequestSettings]): Settings for handling the paused request using `fetch.fulfillRequest`. Defaults to None.
|
|
982
|
+
continue_response (Optional[ContinueResponseSettings]): Settings for handling the paused request using `fetch.continueResponse`. Defaults to None.
|
|
983
|
+
"""
|
|
984
|
+
|
|
985
|
+
continue_request: Optional[ContinueRequestSettings] = None
|
|
986
|
+
fail_request: Optional[FailRequestSettings] = None
|
|
987
|
+
fulfill_request: Optional[FulfillRequestSettings] = None
|
|
988
|
+
continue_response: Optional[ContinueResponseSettings] = None
|
|
989
|
+
|
|
990
|
+
def to_dict(self) -> _RequestPausedActions:
|
|
991
|
+
"""
|
|
992
|
+
Converts the settings object to its dictionary representation.
|
|
993
|
+
|
|
994
|
+
Returns:
|
|
995
|
+
_RequestPausedActions: The dictionary representation suitable for internal use.
|
|
996
|
+
"""
|
|
997
|
+
|
|
998
|
+
return _RequestPausedActions(
|
|
999
|
+
continue_request=self.continue_request.to_dict()
|
|
1000
|
+
if self.continue_request
|
|
1001
|
+
else None,
|
|
1002
|
+
fail_request=self.fail_request.to_dict()
|
|
1003
|
+
if self.fail_request
|
|
1004
|
+
else None,
|
|
1005
|
+
fulfill_request=self.fulfill_request.to_dict()
|
|
1006
|
+
if self.fulfill_request
|
|
1007
|
+
else None,
|
|
1008
|
+
continue_response=self.continue_response.to_dict()
|
|
1009
|
+
if self.continue_response
|
|
1010
|
+
else None,
|
|
1011
|
+
)
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
@dataclass
|
|
1015
|
+
class RequestPausedActionsHandlerSettings(AbstractEventActionsHandlerSettings):
|
|
1016
|
+
"""
|
|
1017
|
+
Settings for handling the 'fetch.RequestPaused' event by choosing and executing specific actions.
|
|
1018
|
+
|
|
1019
|
+
Attributes:
|
|
1020
|
+
choose_action_func (request_paused_choose_action_func_type): A function that takes the DevTools instance and the event object and returns a list of action names (Literals) to execute. Defaults to `request_paused_choose_func`.
|
|
1021
|
+
actions (Optional[RequestPausedActionsSettings]): Container for the configuration of the available actions. Defaults to None.
|
|
1022
|
+
"""
|
|
1023
|
+
|
|
1024
|
+
choose_action_func: "request_paused_choose_action_func_type" = request_paused_choose_func
|
|
1025
|
+
actions: Optional[RequestPausedActionsSettings] = None
|
|
1026
|
+
|
|
1027
|
+
def to_dict(self) -> _RequestPausedActionsHandler:
|
|
1028
|
+
"""
|
|
1029
|
+
Converts the settings object to its dictionary representation.
|
|
1030
|
+
|
|
1031
|
+
Returns:
|
|
1032
|
+
_RequestPausedActionsHandler: The dictionary representation suitable for internal use.
|
|
1033
|
+
"""
|
|
1034
|
+
|
|
1035
|
+
return _RequestPausedActionsHandler(
|
|
1036
|
+
choose_action_func=self.choose_action_func,
|
|
1037
|
+
actions=self.actions.to_dict()
|
|
1038
|
+
if self.actions is not None
|
|
1039
|
+
else RequestPausedActionsSettings().to_dict(),
|
|
1040
|
+
)
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
@dataclass
|
|
1044
|
+
class RequestPausedSettings(AbstractEventSettings):
|
|
1045
|
+
"""
|
|
1046
|
+
Settings for handling the 'fetch.RequestPaused' event.
|
|
1047
|
+
|
|
1048
|
+
This dataclass allows configuring the listener for the 'RequestPaused' CDP event,
|
|
1049
|
+
including buffer size, the actions to take, and error handling.
|
|
1050
|
+
|
|
1051
|
+
Attributes:
|
|
1052
|
+
listen_buffer_size (int): The buffer size for the event listener channel. Defaults to 100.
|
|
1053
|
+
actions_handler (Optional[RequestPausedActionsHandlerSettings]): Configuration for the event's actions handler, determining which action(s) to take (e.g., continueRequest, fulfillRequest) and how to build their parameters. Defaults to None.
|
|
1054
|
+
on_error_func (on_error_func_type): An optional function to call if an error occurs during event handling. Defaults to None.
|
|
1055
|
+
"""
|
|
1056
|
+
|
|
1057
|
+
listen_buffer_size: int = 100
|
|
1058
|
+
actions_handler: Optional[RequestPausedActionsHandlerSettings] = None
|
|
1059
|
+
on_error_func: on_error_func_type = None
|
|
1060
|
+
|
|
1061
|
+
@property
|
|
1062
|
+
def handle_function(self) -> "handle_request_paused_func_type":
|
|
1063
|
+
"""
|
|
1064
|
+
Returns the main handler function for the 'fetch.RequestPaused' event.
|
|
1065
|
+
|
|
1066
|
+
Returns:
|
|
1067
|
+
handle_request_paused_func_type: The internal function `_handle_request_paused`.
|
|
1068
|
+
"""
|
|
1069
|
+
|
|
1070
|
+
return _handle_request_paused
|
|
1071
|
+
|
|
1072
|
+
@property
|
|
1073
|
+
def class_to_use_path(self) -> str:
|
|
1074
|
+
"""
|
|
1075
|
+
Returns the path to the CDP event class for 'fetch.RequestPaused'.
|
|
1076
|
+
|
|
1077
|
+
Returns:
|
|
1078
|
+
str: The string "fetch.RequestPaused".
|
|
1079
|
+
"""
|
|
1080
|
+
|
|
1081
|
+
return "fetch.RequestPaused"
|
|
1082
|
+
|
|
1083
|
+
def to_dict(self) -> _RequestPaused:
|
|
1084
|
+
"""
|
|
1085
|
+
Converts the settings object to its dictionary representation.
|
|
1086
|
+
|
|
1087
|
+
Returns:
|
|
1088
|
+
_RequestPaused: The dictionary representation suitable for internal use.
|
|
1089
|
+
"""
|
|
1090
|
+
|
|
1091
|
+
return _RequestPaused(
|
|
1092
|
+
class_to_use_path=self.class_to_use_path,
|
|
1093
|
+
listen_buffer_size=self.listen_buffer_size,
|
|
1094
|
+
handle_function=self.handle_function,
|
|
1095
|
+
actions_handler=self.actions_handler.to_dict()
|
|
1096
|
+
if self.actions_handler is not None
|
|
1097
|
+
else RequestPausedActionsHandlerSettings().to_dict(),
|
|
1098
|
+
on_error_func=self.on_error_func,
|
|
1099
|
+
)
|
|
1100
|
+
|
|
1101
|
+
|
|
1102
|
+
class _FetchHandlers(TypedDict):
|
|
1103
|
+
"""
|
|
1104
|
+
Internal TypedDict for all event handlers within the Fetch domain.
|
|
1105
|
+
|
|
1106
|
+
Attributes:
|
|
1107
|
+
request_paused (Optional[_RequestPaused]): Configuration for the 'RequestPaused' event handler.
|
|
1108
|
+
auth_required (Optional[_AuthRequired]): Configuration for the 'AuthRequired' event handler.
|
|
1109
|
+
"""
|
|
1110
|
+
|
|
1111
|
+
request_paused: Optional[_RequestPaused]
|
|
1112
|
+
auth_required: Optional[_AuthRequired]
|
|
1113
|
+
|
|
1114
|
+
|
|
1115
|
+
@dataclass
|
|
1116
|
+
class FetchHandlersSettings(AbstractDomainHandlersSettings):
|
|
1117
|
+
"""
|
|
1118
|
+
Container for all handler settings within the Fetch domain.
|
|
1119
|
+
|
|
1120
|
+
Attributes:
|
|
1121
|
+
request_paused (Optional[RequestPausedSettings]): Settings for the 'RequestPaused' event handler. Defaults to None.
|
|
1122
|
+
auth_required (Optional[AuthRequiredSettings]): Settings for the 'AuthRequired' event handler. Defaults to None.
|
|
1123
|
+
"""
|
|
1124
|
+
|
|
1125
|
+
request_paused: Optional[RequestPausedSettings] = None
|
|
1126
|
+
auth_required: Optional[AuthRequiredSettings] = None
|
|
1127
|
+
|
|
1128
|
+
def to_dict(self) -> _FetchHandlers:
|
|
1129
|
+
"""
|
|
1130
|
+
Converts the settings object to its dictionary representation.
|
|
1131
|
+
|
|
1132
|
+
Returns:
|
|
1133
|
+
_FetchHandlers: The dictionary representation suitable for internal use.
|
|
1134
|
+
"""
|
|
1135
|
+
|
|
1136
|
+
return _FetchHandlers(
|
|
1137
|
+
request_paused=self.request_paused.to_dict()
|
|
1138
|
+
if self.request_paused is not None
|
|
1139
|
+
else None,
|
|
1140
|
+
auth_required=self.auth_required.to_dict()
|
|
1141
|
+
if self.auth_required is not None
|
|
1142
|
+
else None,
|
|
1143
|
+
)
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
class _FetchEnableKwargs(TypedDict, total=False):
|
|
1147
|
+
"""
|
|
1148
|
+
Internal TypedDict for keyword arguments to enable the Fetch domain.
|
|
1149
|
+
|
|
1150
|
+
Attributes:
|
|
1151
|
+
patterns (Optional[Sequence[Any]]): A list of request patterns to intercept.
|
|
1152
|
+
handle_auth_requests (Optional[bool]): Whether to intercept authentication requests.
|
|
1153
|
+
"""
|
|
1154
|
+
|
|
1155
|
+
patterns: Optional[Sequence[Any]]
|
|
1156
|
+
handle_auth_requests: Optional[bool]
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
@dataclass
|
|
1160
|
+
class FetchEnableKwargsSettings(AbstractDomainEnableKwargsSettings):
|
|
1161
|
+
"""
|
|
1162
|
+
Keyword arguments for enabling the Fetch domain using `fetch.enable`.
|
|
1163
|
+
|
|
1164
|
+
These settings are passed to the `fetch.enable` CDP command when the Fetch domain is activated.
|
|
1165
|
+
|
|
1166
|
+
Attributes:
|
|
1167
|
+
patterns (Optional[Sequence[Any]]): A list of request patterns to intercept. Each pattern is typically a dictionary matching the CDP `Fetch.RequestPattern` type. If None, all requests are intercepted. Defaults to None.
|
|
1168
|
+
handle_auth_requests (Optional[bool]): Whether to intercept authentication requests (`fetch.AuthRequired` events). If True, `auth_required` events will be emitted. Defaults to None.
|
|
1169
|
+
"""
|
|
1170
|
+
|
|
1171
|
+
patterns: Optional[Sequence[Any]] = None
|
|
1172
|
+
handle_auth_requests: Optional[bool] = None
|
|
1173
|
+
|
|
1174
|
+
def to_dict(self) -> _FetchEnableKwargs:
|
|
1175
|
+
"""
|
|
1176
|
+
Converts the settings object to its dictionary representation.
|
|
1177
|
+
|
|
1178
|
+
Returns:
|
|
1179
|
+
_FetchEnableKwargs: The dictionary representation suitable for internal use.
|
|
1180
|
+
"""
|
|
1181
|
+
|
|
1182
|
+
kwargs = {}
|
|
1183
|
+
|
|
1184
|
+
if self.patterns is not None:
|
|
1185
|
+
kwargs["patterns"] = self.patterns
|
|
1186
|
+
|
|
1187
|
+
if self.handle_auth_requests is not None:
|
|
1188
|
+
kwargs["handle_auth_requests"] = self.handle_auth_requests
|
|
1189
|
+
|
|
1190
|
+
return _FetchEnableKwargs(**kwargs)
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
class _Fetch(AbstractDomain):
|
|
1194
|
+
"""
|
|
1195
|
+
Internal TypedDict for the complete Fetch domain configuration.
|
|
1196
|
+
|
|
1197
|
+
This structure is used internally by the DevTools manager to configure the
|
|
1198
|
+
Fetch domain, including how to enable/disable it and what event handlers to use.
|
|
1199
|
+
|
|
1200
|
+
Attributes:
|
|
1201
|
+
name (str): The name of the domain ('fetch').
|
|
1202
|
+
enable_func_path (str): The path to the function to enable the domain ("fetch.enable").
|
|
1203
|
+
enable_func_kwargs (Optional[_FetchEnableKwargs]): Keyword arguments for the enable function.
|
|
1204
|
+
disable_func_path (str): The path to the function to disable the domain ("fetch.disable").
|
|
1205
|
+
handlers (_FetchHandlers): The configured event handlers for the domain.
|
|
1206
|
+
"""
|
|
1207
|
+
|
|
1208
|
+
name: str
|
|
1209
|
+
enable_func_path: str
|
|
1210
|
+
enable_func_kwargs: Optional[_FetchEnableKwargs]
|
|
1211
|
+
disable_func_path: str
|
|
1212
|
+
handlers: _FetchHandlers
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
@dataclass
|
|
1216
|
+
class FetchSettings(AbstractDomainSettings):
|
|
1217
|
+
"""
|
|
1218
|
+
Top-level configuration for the Fetch domain.
|
|
1219
|
+
|
|
1220
|
+
This dataclass allows configuring the entire Fetch CDP domain within the DevTools manager,
|
|
1221
|
+
including its enabling parameters and event handlers.
|
|
1222
|
+
|
|
1223
|
+
Attributes:
|
|
1224
|
+
enable_func_kwargs (Optional[FetchEnableKwargsSettings]): Keyword arguments for enabling the Fetch domain using `fetch.enable`. Defaults to None.
|
|
1225
|
+
handlers (FetchHandlersSettings): Container for all handler settings within the Fetch domain (e.g., RequestPaused, AuthRequired). Defaults to None.
|
|
1226
|
+
"""
|
|
1227
|
+
|
|
1228
|
+
enable_func_kwargs: Optional[FetchEnableKwargsSettings] = None
|
|
1229
|
+
handlers: Optional[FetchHandlersSettings] = None
|
|
1230
|
+
|
|
1231
|
+
@property
|
|
1232
|
+
def disable_func_path(self) -> str:
|
|
1233
|
+
"""
|
|
1234
|
+
Returns the path to the function to disable the domain.
|
|
1235
|
+
|
|
1236
|
+
Returns:
|
|
1237
|
+
str: The string "fetch.disable".
|
|
1238
|
+
"""
|
|
1239
|
+
|
|
1240
|
+
return "fetch.disable"
|
|
1241
|
+
|
|
1242
|
+
@property
|
|
1243
|
+
def enable_func_path(self) -> str:
|
|
1244
|
+
"""
|
|
1245
|
+
Returns the path to the function to enable the domain.
|
|
1246
|
+
|
|
1247
|
+
Returns:
|
|
1248
|
+
str: The string "fetch.enable".
|
|
1249
|
+
"""
|
|
1250
|
+
|
|
1251
|
+
return "fetch.enable"
|
|
1252
|
+
|
|
1253
|
+
@property
|
|
1254
|
+
def name(self) -> str:
|
|
1255
|
+
"""
|
|
1256
|
+
Returns the name of the domain.
|
|
1257
|
+
|
|
1258
|
+
Returns:
|
|
1259
|
+
str: The string "fetch".
|
|
1260
|
+
"""
|
|
1261
|
+
|
|
1262
|
+
return "fetch"
|
|
1263
|
+
|
|
1264
|
+
def to_dict(self) -> _Fetch:
|
|
1265
|
+
"""
|
|
1266
|
+
Converts the settings object to its dictionary representation.
|
|
1267
|
+
|
|
1268
|
+
Returns:
|
|
1269
|
+
_Fetch: The dictionary representation suitable for internal use.
|
|
1270
|
+
"""
|
|
1271
|
+
|
|
1272
|
+
return _Fetch(
|
|
1273
|
+
name=self.name,
|
|
1274
|
+
enable_func_path=self.enable_func_path,
|
|
1275
|
+
enable_func_kwargs=self.enable_func_kwargs.to_dict()
|
|
1276
|
+
if self.enable_func_kwargs is not None
|
|
1277
|
+
else FetchEnableKwargsSettings().to_dict(),
|
|
1278
|
+
disable_func_path=self.disable_func_path,
|
|
1279
|
+
handlers=self.handlers.to_dict()
|
|
1280
|
+
if self.handlers is not None
|
|
1281
|
+
else FetchHandlersSettings().to_dict(),
|
|
1282
|
+
)
|
|
1283
|
+
|
|
1284
|
+
|
|
1285
|
+
request_paused_actions_literal = Literal[
|
|
1286
|
+
"continue_request",
|
|
1287
|
+
"fail_request",
|
|
1288
|
+
"fulfill_request",
|
|
1289
|
+
"continue_response"
|
|
1290
|
+
]
|
|
1291
|
+
auth_required_actions_literal = Literal["continue_with_auth"]
|
|
1292
|
+
request_paused_choose_action_func_type = Callable[["DevToolsTarget", Any], Sequence[request_paused_actions_literal]]
|
|
1293
|
+
auth_required_choose_action_func_type = Callable[["DevToolsTarget", Any], Sequence[auth_required_actions_literal]]
|
|
1294
|
+
handle_request_paused_func_type = Callable[["DevToolsTarget", _RequestPaused, Any], Awaitable[None]]
|
|
1295
|
+
handle_auth_required_func_type = Callable[["DevToolsTarget", _AuthRequired, Any], Awaitable[None]]
|