mithwire 0.50.3__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.
Files changed (76) hide show
  1. mithwire/__init__.py +32 -0
  2. mithwire/cdp/README.md +4 -0
  3. mithwire/cdp/__init__.py +6 -0
  4. mithwire/cdp/accessibility.py +668 -0
  5. mithwire/cdp/animation.py +494 -0
  6. mithwire/cdp/audits.py +1995 -0
  7. mithwire/cdp/autofill.py +292 -0
  8. mithwire/cdp/background_service.py +215 -0
  9. mithwire/cdp/bluetooth_emulation.py +626 -0
  10. mithwire/cdp/browser.py +821 -0
  11. mithwire/cdp/cache_storage.py +311 -0
  12. mithwire/cdp/cast.py +172 -0
  13. mithwire/cdp/console.py +107 -0
  14. mithwire/cdp/crash_report_context.py +55 -0
  15. mithwire/cdp/css.py +2750 -0
  16. mithwire/cdp/database.py +179 -0
  17. mithwire/cdp/debugger.py +1405 -0
  18. mithwire/cdp/device_access.py +141 -0
  19. mithwire/cdp/device_orientation.py +45 -0
  20. mithwire/cdp/dom.py +2257 -0
  21. mithwire/cdp/dom_debugger.py +321 -0
  22. mithwire/cdp/dom_snapshot.py +876 -0
  23. mithwire/cdp/dom_storage.py +222 -0
  24. mithwire/cdp/emulation.py +1779 -0
  25. mithwire/cdp/event_breakpoints.py +56 -0
  26. mithwire/cdp/extensions.py +238 -0
  27. mithwire/cdp/fed_cm.py +283 -0
  28. mithwire/cdp/fetch.py +507 -0
  29. mithwire/cdp/file_system.py +115 -0
  30. mithwire/cdp/headless_experimental.py +115 -0
  31. mithwire/cdp/heap_profiler.py +401 -0
  32. mithwire/cdp/indexed_db.py +528 -0
  33. mithwire/cdp/input_.py +701 -0
  34. mithwire/cdp/inspector.py +95 -0
  35. mithwire/cdp/io.py +101 -0
  36. mithwire/cdp/layer_tree.py +464 -0
  37. mithwire/cdp/log.py +190 -0
  38. mithwire/cdp/media.py +313 -0
  39. mithwire/cdp/memory.py +305 -0
  40. mithwire/cdp/network.py +5342 -0
  41. mithwire/cdp/overlay.py +1468 -0
  42. mithwire/cdp/page.py +3972 -0
  43. mithwire/cdp/performance.py +124 -0
  44. mithwire/cdp/performance_timeline.py +200 -0
  45. mithwire/cdp/preload.py +575 -0
  46. mithwire/cdp/profiler.py +420 -0
  47. mithwire/cdp/pwa.py +278 -0
  48. mithwire/cdp/py.typed +0 -0
  49. mithwire/cdp/runtime.py +1589 -0
  50. mithwire/cdp/schema.py +50 -0
  51. mithwire/cdp/security.py +518 -0
  52. mithwire/cdp/service_worker.py +401 -0
  53. mithwire/cdp/smart_card_emulation.py +891 -0
  54. mithwire/cdp/storage.py +1573 -0
  55. mithwire/cdp/system_info.py +327 -0
  56. mithwire/cdp/target.py +829 -0
  57. mithwire/cdp/tethering.py +65 -0
  58. mithwire/cdp/tracing.py +377 -0
  59. mithwire/cdp/util.py +18 -0
  60. mithwire/cdp/web_audio.py +606 -0
  61. mithwire/cdp/web_authn.py +598 -0
  62. mithwire/cdp/web_mcp.py +293 -0
  63. mithwire/core/_contradict.py +142 -0
  64. mithwire/core/browser.py +923 -0
  65. mithwire/core/cf_templates/cf_dark_checkbox.png +0 -0
  66. mithwire/core/cf_templates/cf_light_checkbox.png +0 -0
  67. mithwire/core/config.py +323 -0
  68. mithwire/core/connection.py +564 -0
  69. mithwire/core/element.py +1205 -0
  70. mithwire/core/tab.py +2202 -0
  71. mithwire/core/util.py +5063 -0
  72. mithwire-0.50.3.dist-info/METADATA +1049 -0
  73. mithwire-0.50.3.dist-info/RECORD +76 -0
  74. mithwire-0.50.3.dist-info/WHEEL +5 -0
  75. mithwire-0.50.3.dist-info/licenses/LICENSE.txt +619 -0
  76. mithwire-0.50.3.dist-info/top_level.txt +1 -0
mithwire/cdp/target.py ADDED
@@ -0,0 +1,829 @@
1
+ # DO NOT EDIT THIS FILE!
2
+ #
3
+ # This file is generated from the CDP specification. If you need to make
4
+ # changes, edit the generator and regenerate all of the modules.
5
+ #
6
+ # CDP domain: Target
7
+
8
+ from __future__ import annotations
9
+ import enum
10
+ import typing
11
+ from dataclasses import dataclass
12
+ from .util import event_class, T_JSON_DICT
13
+
14
+ from . import browser
15
+ from . import page
16
+ from deprecated.sphinx import deprecated # type: ignore
17
+
18
+
19
+ class TargetID(str):
20
+ def to_json(self) -> str:
21
+ return self
22
+
23
+ @classmethod
24
+ def from_json(cls, json: str) -> TargetID:
25
+ return cls(json)
26
+
27
+ def __repr__(self):
28
+ return 'TargetID({})'.format(super().__repr__())
29
+
30
+
31
+ class SessionID(str):
32
+ '''
33
+ Unique identifier of attached debugging session.
34
+ '''
35
+ def to_json(self) -> str:
36
+ return self
37
+
38
+ @classmethod
39
+ def from_json(cls, json: str) -> SessionID:
40
+ return cls(json)
41
+
42
+ def __repr__(self):
43
+ return 'SessionID({})'.format(super().__repr__())
44
+
45
+
46
+ @dataclass
47
+ class TargetInfo:
48
+ target_id: TargetID
49
+
50
+ #: List of types: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/devtools_agent_host_impl.cc?ss=chromium&q=f:devtools%20-f:out%20%22::kTypeTab%5B%5D%22
51
+ type_: str
52
+
53
+ title: str
54
+
55
+ url: str
56
+
57
+ #: Whether the target has an attached client.
58
+ attached: bool
59
+
60
+ #: Whether the target has access to the originating window.
61
+ can_access_opener: bool
62
+
63
+ #: Id of the parent target, if any. For example, "iframe" target may have a "page" parent.
64
+ parent_id: typing.Optional[TargetID] = None
65
+
66
+ #: Opener target Id
67
+ opener_id: typing.Optional[TargetID] = None
68
+
69
+ #: Frame id of originating window (is only set if target has an opener).
70
+ opener_frame_id: typing.Optional[page.FrameId] = None
71
+
72
+ #: Id of the parent frame, present for "iframe" and "worker" targets. For nested workers,
73
+ #: this is the "ancestor" frame that created the first worker in the nested chain.
74
+ parent_frame_id: typing.Optional[page.FrameId] = None
75
+
76
+ browser_context_id: typing.Optional[browser.BrowserContextID] = None
77
+
78
+ #: Provides additional details for specific target types. For example, for
79
+ #: the type of "page", this may be set to "prerender".
80
+ subtype: typing.Optional[str] = None
81
+
82
+ def to_json(self) -> T_JSON_DICT:
83
+ json: T_JSON_DICT = dict()
84
+ json['targetId'] = self.target_id.to_json()
85
+ json['type'] = self.type_
86
+ json['title'] = self.title
87
+ json['url'] = self.url
88
+ json['attached'] = self.attached
89
+ json['canAccessOpener'] = self.can_access_opener
90
+ if self.parent_id is not None:
91
+ json['parentId'] = self.parent_id.to_json()
92
+ if self.opener_id is not None:
93
+ json['openerId'] = self.opener_id.to_json()
94
+ if self.opener_frame_id is not None:
95
+ json['openerFrameId'] = self.opener_frame_id.to_json()
96
+ if self.parent_frame_id is not None:
97
+ json['parentFrameId'] = self.parent_frame_id.to_json()
98
+ if self.browser_context_id is not None:
99
+ json['browserContextId'] = self.browser_context_id.to_json()
100
+ if self.subtype is not None:
101
+ json['subtype'] = self.subtype
102
+ return json
103
+
104
+ @classmethod
105
+ def from_json(cls, json: T_JSON_DICT) -> TargetInfo:
106
+ return cls(
107
+ target_id=TargetID.from_json(json['targetId']),
108
+ type_=str(json['type']),
109
+ title=str(json['title']),
110
+ url=str(json['url']),
111
+ attached=bool(json['attached']),
112
+ can_access_opener=bool(json['canAccessOpener']),
113
+ parent_id=TargetID.from_json(json['parentId']) if json.get('parentId', None) is not None else None,
114
+ opener_id=TargetID.from_json(json['openerId']) if json.get('openerId', None) is not None else None,
115
+ opener_frame_id=page.FrameId.from_json(json['openerFrameId']) if json.get('openerFrameId', None) is not None else None,
116
+ parent_frame_id=page.FrameId.from_json(json['parentFrameId']) if json.get('parentFrameId', None) is not None else None,
117
+ browser_context_id=browser.BrowserContextID.from_json(json['browserContextId']) if json.get('browserContextId', None) is not None else None,
118
+ subtype=str(json['subtype']) if json.get('subtype', None) is not None else None,
119
+ )
120
+
121
+
122
+ @dataclass
123
+ class FilterEntry:
124
+ '''
125
+ A filter used by target query/discovery/auto-attach operations.
126
+ '''
127
+ #: If set, causes exclusion of matching targets from the list.
128
+ exclude: typing.Optional[bool] = None
129
+
130
+ #: If not present, matches any type.
131
+ type_: typing.Optional[str] = None
132
+
133
+ def to_json(self) -> T_JSON_DICT:
134
+ json: T_JSON_DICT = dict()
135
+ if self.exclude is not None:
136
+ json['exclude'] = self.exclude
137
+ if self.type_ is not None:
138
+ json['type'] = self.type_
139
+ return json
140
+
141
+ @classmethod
142
+ def from_json(cls, json: T_JSON_DICT) -> FilterEntry:
143
+ return cls(
144
+ exclude=bool(json['exclude']) if json.get('exclude', None) is not None else None,
145
+ type_=str(json['type']) if json.get('type', None) is not None else None,
146
+ )
147
+
148
+
149
+ class TargetFilter(list):
150
+ '''
151
+ The entries in TargetFilter are matched sequentially against targets and
152
+ the first entry that matches determines if the target is included or not,
153
+ depending on the value of ``exclude`` field in the entry.
154
+ If filter is not specified, the one assumed is
155
+ [{type: "browser", exclude: true}, {type: "tab", exclude: true}, {}]
156
+ (i.e. include everything but ``browser`` and ``tab``).
157
+ '''
158
+ def to_json(self) -> typing.List[FilterEntry]:
159
+ return self
160
+
161
+ @classmethod
162
+ def from_json(cls, json: typing.List[FilterEntry]) -> TargetFilter:
163
+ return cls(json)
164
+
165
+ def __repr__(self):
166
+ return 'TargetFilter({})'.format(super().__repr__())
167
+
168
+
169
+ @dataclass
170
+ class RemoteLocation:
171
+ host: str
172
+
173
+ port: int
174
+
175
+ def to_json(self) -> T_JSON_DICT:
176
+ json: T_JSON_DICT = dict()
177
+ json['host'] = self.host
178
+ json['port'] = self.port
179
+ return json
180
+
181
+ @classmethod
182
+ def from_json(cls, json: T_JSON_DICT) -> RemoteLocation:
183
+ return cls(
184
+ host=str(json['host']),
185
+ port=int(json['port']),
186
+ )
187
+
188
+
189
+ class WindowState(enum.Enum):
190
+ '''
191
+ The state of the target window.
192
+ '''
193
+ NORMAL = "normal"
194
+ MINIMIZED = "minimized"
195
+ MAXIMIZED = "maximized"
196
+ FULLSCREEN = "fullscreen"
197
+
198
+ def to_json(self) -> str:
199
+ return self.value
200
+
201
+ @classmethod
202
+ def from_json(cls, json: str) -> WindowState:
203
+ return cls(json)
204
+
205
+
206
+ def activate_target(
207
+ target_id: TargetID
208
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
209
+ '''
210
+ Activates (focuses) the target.
211
+
212
+ :param target_id:
213
+ '''
214
+ params: T_JSON_DICT = dict()
215
+ params['targetId'] = target_id.to_json()
216
+ cmd_dict: T_JSON_DICT = {
217
+ 'method': 'Target.activateTarget',
218
+ 'params': params,
219
+ }
220
+ json = yield cmd_dict
221
+
222
+
223
+ def attach_to_target(
224
+ target_id: TargetID,
225
+ flatten: typing.Optional[bool] = None
226
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SessionID]:
227
+ '''
228
+ Attaches to the target with given id.
229
+
230
+ :param target_id:
231
+ :param flatten: *(Optional)* Enables "flat" access to the session via specifying sessionId attribute in the commands. We plan to make this the default, deprecate non-flattened mode, and eventually retire it. See crbug.com/991325.
232
+ :returns: Id assigned to the session.
233
+ '''
234
+ params: T_JSON_DICT = dict()
235
+ params['targetId'] = target_id.to_json()
236
+ if flatten is not None:
237
+ params['flatten'] = flatten
238
+ cmd_dict: T_JSON_DICT = {
239
+ 'method': 'Target.attachToTarget',
240
+ 'params': params,
241
+ }
242
+ json = yield cmd_dict
243
+ return SessionID.from_json(json['sessionId'])
244
+
245
+
246
+ def attach_to_browser_target() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SessionID]:
247
+ '''
248
+ Attaches to the browser target, only uses flat sessionId mode.
249
+
250
+ **EXPERIMENTAL**
251
+
252
+ :returns: Id assigned to the session.
253
+ '''
254
+ cmd_dict: T_JSON_DICT = {
255
+ 'method': 'Target.attachToBrowserTarget',
256
+ }
257
+ json = yield cmd_dict
258
+ return SessionID.from_json(json['sessionId'])
259
+
260
+
261
+ def close_target(
262
+ target_id: TargetID
263
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,bool]:
264
+ '''
265
+ Closes the target. If the target is a page that gets closed too.
266
+
267
+ :param target_id:
268
+ :returns: Always set to true. If an error occurs, the response indicates protocol error.
269
+ '''
270
+ params: T_JSON_DICT = dict()
271
+ params['targetId'] = target_id.to_json()
272
+ cmd_dict: T_JSON_DICT = {
273
+ 'method': 'Target.closeTarget',
274
+ 'params': params,
275
+ }
276
+ json = yield cmd_dict
277
+ return bool(json['success'])
278
+
279
+
280
+ def expose_dev_tools_protocol(
281
+ target_id: TargetID,
282
+ binding_name: typing.Optional[str] = None,
283
+ inherit_permissions: typing.Optional[bool] = None
284
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
285
+ '''
286
+ Inject object to the target's main frame that provides a communication
287
+ channel with browser target.
288
+
289
+ Injected object will be available as ``window[bindingName]``.
290
+
291
+ The object has the following API:
292
+ - ``binding.send(json)`` - a method to send messages over the remote debugging protocol
293
+ - ``binding.onmessage = json => handleMessage(json)`` - a callback that will be called for the protocol notifications and command responses.
294
+
295
+ **EXPERIMENTAL**
296
+
297
+ :param target_id:
298
+ :param binding_name: *(Optional)* Binding name, 'cdp' if not specified.
299
+ :param inherit_permissions: *(Optional)* If true, inherits the current root session's permissions (default: false).
300
+ '''
301
+ params: T_JSON_DICT = dict()
302
+ params['targetId'] = target_id.to_json()
303
+ if binding_name is not None:
304
+ params['bindingName'] = binding_name
305
+ if inherit_permissions is not None:
306
+ params['inheritPermissions'] = inherit_permissions
307
+ cmd_dict: T_JSON_DICT = {
308
+ 'method': 'Target.exposeDevToolsProtocol',
309
+ 'params': params,
310
+ }
311
+ json = yield cmd_dict
312
+
313
+
314
+ def create_browser_context(
315
+ dispose_on_detach: typing.Optional[bool] = None,
316
+ proxy_server: typing.Optional[str] = None,
317
+ proxy_bypass_list: typing.Optional[str] = None,
318
+ origins_with_universal_network_access: typing.Optional[typing.List[str]] = None
319
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,browser.BrowserContextID]:
320
+ '''
321
+ Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than
322
+ one.
323
+
324
+ :param dispose_on_detach: **(EXPERIMENTAL)** *(Optional)* If specified, disposes this context when debugging session disconnects.
325
+ :param proxy_server: **(EXPERIMENTAL)** *(Optional)* Proxy server, similar to the one passed to --proxy-server
326
+ :param proxy_bypass_list: **(EXPERIMENTAL)** *(Optional)* Proxy bypass list, similar to the one passed to --proxy-bypass-list
327
+ :param origins_with_universal_network_access: **(EXPERIMENTAL)** *(Optional)* An optional list of origins to grant unlimited cross-origin access to. Parts of the URL other than those constituting origin are ignored.
328
+ :returns: The id of the context created.
329
+ '''
330
+ params: T_JSON_DICT = dict()
331
+ if dispose_on_detach is not None:
332
+ params['disposeOnDetach'] = dispose_on_detach
333
+ if proxy_server is not None:
334
+ params['proxyServer'] = proxy_server
335
+ if proxy_bypass_list is not None:
336
+ params['proxyBypassList'] = proxy_bypass_list
337
+ if origins_with_universal_network_access is not None:
338
+ params['originsWithUniversalNetworkAccess'] = [i for i in origins_with_universal_network_access]
339
+ cmd_dict: T_JSON_DICT = {
340
+ 'method': 'Target.createBrowserContext',
341
+ 'params': params,
342
+ }
343
+ json = yield cmd_dict
344
+ return browser.BrowserContextID.from_json(json['browserContextId'])
345
+
346
+
347
+ def get_browser_contexts() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[typing.List[browser.BrowserContextID], typing.Optional[browser.BrowserContextID]]]:
348
+ '''
349
+ Returns all browser contexts created with ``Target.createBrowserContext`` method.
350
+
351
+ :returns: A tuple with the following items:
352
+
353
+ 0. **browserContextIds** - An array of browser context ids.
354
+ 1. **defaultBrowserContextId** - *(Optional)* The id of the default browser context if available.
355
+ '''
356
+ cmd_dict: T_JSON_DICT = {
357
+ 'method': 'Target.getBrowserContexts',
358
+ }
359
+ json = yield cmd_dict
360
+ return (
361
+ [browser.BrowserContextID.from_json(i) for i in json['browserContextIds']],
362
+ browser.BrowserContextID.from_json(json['defaultBrowserContextId']) if json.get('defaultBrowserContextId', None) is not None else None
363
+ )
364
+
365
+
366
+ def create_target(
367
+ url: str,
368
+ left: typing.Optional[int] = None,
369
+ top: typing.Optional[int] = None,
370
+ width: typing.Optional[int] = None,
371
+ height: typing.Optional[int] = None,
372
+ window_state: typing.Optional[WindowState] = None,
373
+ browser_context_id: typing.Optional[browser.BrowserContextID] = None,
374
+ enable_begin_frame_control: typing.Optional[bool] = None,
375
+ new_window: typing.Optional[bool] = None,
376
+ background: typing.Optional[bool] = None,
377
+ for_tab: typing.Optional[bool] = None,
378
+ hidden: typing.Optional[bool] = None,
379
+ focus: typing.Optional[bool] = None
380
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,TargetID]:
381
+ '''
382
+ Creates a new page.
383
+
384
+ :param url: The initial URL the page will be navigated to. An empty string indicates about:blank.
385
+ :param left: **(EXPERIMENTAL)** *(Optional)* Frame left origin in DIP (requires newWindow to be true or headless shell).
386
+ :param top: **(EXPERIMENTAL)** *(Optional)* Frame top origin in DIP (requires newWindow to be true or headless shell).
387
+ :param width: *(Optional)* Frame width in DIP (requires newWindow to be true or headless shell).
388
+ :param height: *(Optional)* Frame height in DIP (requires newWindow to be true or headless shell).
389
+ :param window_state: *(Optional)* Frame window state (requires newWindow to be true or headless shell). Default is normal.
390
+ :param browser_context_id: **(EXPERIMENTAL)** *(Optional)* The browser context to create the page in.
391
+ :param enable_begin_frame_control: **(EXPERIMENTAL)** *(Optional)* Whether BeginFrames for this target will be controlled via DevTools (headless shell only, not supported on MacOS yet, false by default).
392
+ :param new_window: *(Optional)* Whether to create a new Window or Tab (false by default, not supported by headless shell).
393
+ :param background: *(Optional)* Whether to create the target in background or foreground (false by default, not supported by headless shell).
394
+ :param for_tab: **(EXPERIMENTAL)** *(Optional)* Whether to create the target of type "tab".
395
+ :param hidden: **(EXPERIMENTAL)** *(Optional)* Whether to create a hidden target. The hidden target is observable via protocol, but not present in the tab UI strip. Cannot be created with ```forTab: true````, ````newWindow: true```` or ````background: false```. The life-time of the tab is limited to the life-time of the session.
396
+ :param focus: **(EXPERIMENTAL)** *(Optional)* If specified, the option is used to determine if the new target should be focused or not. By default, the focus behavior depends on the value of the background field. For example, background=false and focus=false will result in the target tab being opened but the browser window remain unchanged (if it was in the background, it will remain in the background) and background=false with focus=undefined will result in the window being focused. Using background: true and focus: true is not supported and will result in an error.
397
+ :returns: The id of the page opened.
398
+ '''
399
+ params: T_JSON_DICT = dict()
400
+ params['url'] = url
401
+ if left is not None:
402
+ params['left'] = left
403
+ if top is not None:
404
+ params['top'] = top
405
+ if width is not None:
406
+ params['width'] = width
407
+ if height is not None:
408
+ params['height'] = height
409
+ if window_state is not None:
410
+ params['windowState'] = window_state.to_json()
411
+ if browser_context_id is not None:
412
+ params['browserContextId'] = browser_context_id.to_json()
413
+ if enable_begin_frame_control is not None:
414
+ params['enableBeginFrameControl'] = enable_begin_frame_control
415
+ if new_window is not None:
416
+ params['newWindow'] = new_window
417
+ if background is not None:
418
+ params['background'] = background
419
+ if for_tab is not None:
420
+ params['forTab'] = for_tab
421
+ if hidden is not None:
422
+ params['hidden'] = hidden
423
+ if focus is not None:
424
+ params['focus'] = focus
425
+ cmd_dict: T_JSON_DICT = {
426
+ 'method': 'Target.createTarget',
427
+ 'params': params,
428
+ }
429
+ json = yield cmd_dict
430
+ return TargetID.from_json(json['targetId'])
431
+
432
+
433
+ def detach_from_target(
434
+ session_id: typing.Optional[SessionID] = None,
435
+ target_id: typing.Optional[TargetID] = None
436
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
437
+ '''
438
+ Detaches session with given id.
439
+
440
+ :param session_id: *(Optional)* Session to detach.
441
+ :param target_id: **(DEPRECATED)** *(Optional)* Deprecated.
442
+ '''
443
+ params: T_JSON_DICT = dict()
444
+ if session_id is not None:
445
+ params['sessionId'] = session_id.to_json()
446
+ if target_id is not None:
447
+ params['targetId'] = target_id.to_json()
448
+ cmd_dict: T_JSON_DICT = {
449
+ 'method': 'Target.detachFromTarget',
450
+ 'params': params,
451
+ }
452
+ json = yield cmd_dict
453
+
454
+
455
+ def dispose_browser_context(
456
+ browser_context_id: browser.BrowserContextID
457
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
458
+ '''
459
+ Deletes a BrowserContext. All the belonging pages will be closed without calling their
460
+ beforeunload hooks.
461
+
462
+ :param browser_context_id:
463
+ '''
464
+ params: T_JSON_DICT = dict()
465
+ params['browserContextId'] = browser_context_id.to_json()
466
+ cmd_dict: T_JSON_DICT = {
467
+ 'method': 'Target.disposeBrowserContext',
468
+ 'params': params,
469
+ }
470
+ json = yield cmd_dict
471
+
472
+
473
+ def get_target_info(
474
+ target_id: typing.Optional[TargetID] = None
475
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,TargetInfo]:
476
+ '''
477
+ Returns information about a target.
478
+
479
+ **EXPERIMENTAL**
480
+
481
+ :param target_id: *(Optional)*
482
+ :returns:
483
+ '''
484
+ params: T_JSON_DICT = dict()
485
+ if target_id is not None:
486
+ params['targetId'] = target_id.to_json()
487
+ cmd_dict: T_JSON_DICT = {
488
+ 'method': 'Target.getTargetInfo',
489
+ 'params': params,
490
+ }
491
+ json = yield cmd_dict
492
+ return TargetInfo.from_json(json['targetInfo'])
493
+
494
+
495
+ def get_targets(
496
+ filter_: typing.Optional[TargetFilter] = None
497
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[TargetInfo]]:
498
+ '''
499
+ Retrieves a list of available targets.
500
+
501
+ :param filter_: **(EXPERIMENTAL)** *(Optional)* Only targets matching filter will be reported. If filter is not specified and target discovery is currently enabled, a filter used for target discovery is used for consistency.
502
+ :returns: The list of targets.
503
+ '''
504
+ params: T_JSON_DICT = dict()
505
+ if filter_ is not None:
506
+ params['filter'] = filter_.to_json()
507
+ cmd_dict: T_JSON_DICT = {
508
+ 'method': 'Target.getTargets',
509
+ 'params': params,
510
+ }
511
+ json = yield cmd_dict
512
+ return [TargetInfo.from_json(i) for i in json['targetInfos']]
513
+
514
+
515
+ @deprecated(version="1.3")
516
+ def send_message_to_target(
517
+ message: str,
518
+ session_id: typing.Optional[SessionID] = None,
519
+ target_id: typing.Optional[TargetID] = None
520
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
521
+ '''
522
+ Sends protocol message over session with given id.
523
+ Consider using flat mode instead; see commands attachToTarget, setAutoAttach,
524
+ and crbug.com/991325.
525
+
526
+ .. deprecated:: 1.3
527
+
528
+ :param message:
529
+ :param session_id: *(Optional)* Identifier of the session.
530
+ :param target_id: **(DEPRECATED)** *(Optional)* Deprecated.
531
+ '''
532
+ params: T_JSON_DICT = dict()
533
+ params['message'] = message
534
+ if session_id is not None:
535
+ params['sessionId'] = session_id.to_json()
536
+ if target_id is not None:
537
+ params['targetId'] = target_id.to_json()
538
+ cmd_dict: T_JSON_DICT = {
539
+ 'method': 'Target.sendMessageToTarget',
540
+ 'params': params,
541
+ }
542
+ json = yield cmd_dict
543
+
544
+
545
+ def set_auto_attach(
546
+ auto_attach: bool,
547
+ wait_for_debugger_on_start: bool,
548
+ flatten: typing.Optional[bool] = None,
549
+ filter_: typing.Optional[TargetFilter] = None
550
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
551
+ '''
552
+ Controls whether to automatically attach to new targets which are considered
553
+ to be directly related to this one (for example, iframes or workers).
554
+ When turned on, attaches to all existing related targets as well. When turned off,
555
+ automatically detaches from all currently attached targets.
556
+ This also clears all targets added by ``autoAttachRelated`` from the list of targets to watch
557
+ for creation of related targets.
558
+ You might want to call this recursively for auto-attached targets to attach
559
+ to all available targets.
560
+
561
+ :param auto_attach: Whether to auto-attach to related targets.
562
+ :param wait_for_debugger_on_start: Whether to pause new targets when attaching to them. Use ```Runtime.runIfWaitingForDebugger``` to run paused targets.
563
+ :param flatten: **(EXPERIMENTAL)** *(Optional)* Enables "flat" access to the session via specifying sessionId attribute in the commands. We plan to make this the default, deprecate non-flattened mode, and eventually retire it. See crbug.com/991325.
564
+ :param filter_: **(EXPERIMENTAL)** *(Optional)* Only targets matching filter will be attached.
565
+ '''
566
+ params: T_JSON_DICT = dict()
567
+ params['autoAttach'] = auto_attach
568
+ params['waitForDebuggerOnStart'] = wait_for_debugger_on_start
569
+ if flatten is not None:
570
+ params['flatten'] = flatten
571
+ if filter_ is not None:
572
+ params['filter'] = filter_.to_json()
573
+ cmd_dict: T_JSON_DICT = {
574
+ 'method': 'Target.setAutoAttach',
575
+ 'params': params,
576
+ }
577
+ json = yield cmd_dict
578
+
579
+
580
+ def auto_attach_related(
581
+ target_id: TargetID,
582
+ wait_for_debugger_on_start: bool,
583
+ filter_: typing.Optional[TargetFilter] = None
584
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
585
+ '''
586
+ Adds the specified target to the list of targets that will be monitored for any related target
587
+ creation (such as child frames, child workers and new versions of service worker) and reported
588
+ through ``attachedToTarget``. The specified target is also auto-attached.
589
+ This cancels the effect of any previous ``setAutoAttach`` and is also cancelled by subsequent
590
+ ``setAutoAttach``. Only available at the Browser target.
591
+
592
+ **EXPERIMENTAL**
593
+
594
+ :param target_id:
595
+ :param wait_for_debugger_on_start: Whether to pause new targets when attaching to them. Use ```Runtime.runIfWaitingForDebugger``` to run paused targets.
596
+ :param filter_: **(EXPERIMENTAL)** *(Optional)* Only targets matching filter will be attached.
597
+ '''
598
+ params: T_JSON_DICT = dict()
599
+ params['targetId'] = target_id.to_json()
600
+ params['waitForDebuggerOnStart'] = wait_for_debugger_on_start
601
+ if filter_ is not None:
602
+ params['filter'] = filter_.to_json()
603
+ cmd_dict: T_JSON_DICT = {
604
+ 'method': 'Target.autoAttachRelated',
605
+ 'params': params,
606
+ }
607
+ json = yield cmd_dict
608
+
609
+
610
+ def set_discover_targets(
611
+ discover: bool,
612
+ filter_: typing.Optional[TargetFilter] = None
613
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
614
+ '''
615
+ Controls whether to discover available targets and notify via
616
+ ``targetCreated/targetInfoChanged/targetDestroyed`` events.
617
+
618
+ :param discover: Whether to discover available targets.
619
+ :param filter_: **(EXPERIMENTAL)** *(Optional)* Only targets matching filter will be attached. If ```discover```` is false, ````filter``` must be omitted or empty.
620
+ '''
621
+ params: T_JSON_DICT = dict()
622
+ params['discover'] = discover
623
+ if filter_ is not None:
624
+ params['filter'] = filter_.to_json()
625
+ cmd_dict: T_JSON_DICT = {
626
+ 'method': 'Target.setDiscoverTargets',
627
+ 'params': params,
628
+ }
629
+ json = yield cmd_dict
630
+
631
+
632
+ def set_remote_locations(
633
+ locations: typing.List[RemoteLocation]
634
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
635
+ '''
636
+ Enables target discovery for the specified locations, when ``setDiscoverTargets`` was set to
637
+ ``true``.
638
+
639
+ **EXPERIMENTAL**
640
+
641
+ :param locations: List of remote locations.
642
+ '''
643
+ params: T_JSON_DICT = dict()
644
+ params['locations'] = [i.to_json() for i in locations]
645
+ cmd_dict: T_JSON_DICT = {
646
+ 'method': 'Target.setRemoteLocations',
647
+ 'params': params,
648
+ }
649
+ json = yield cmd_dict
650
+
651
+
652
+ def get_dev_tools_target(
653
+ target_id: TargetID
654
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Optional[TargetID]]:
655
+ '''
656
+ Gets the targetId of the DevTools page target opened for the given target
657
+ (if any).
658
+
659
+ **EXPERIMENTAL**
660
+
661
+ :param target_id: Page or tab target ID.
662
+ :returns: *(Optional)* The targetId of DevTools page target if exists.
663
+ '''
664
+ params: T_JSON_DICT = dict()
665
+ params['targetId'] = target_id.to_json()
666
+ cmd_dict: T_JSON_DICT = {
667
+ 'method': 'Target.getDevToolsTarget',
668
+ 'params': params,
669
+ }
670
+ json = yield cmd_dict
671
+ return TargetID.from_json(json['targetId']) if json.get('targetId', None) is not None else None
672
+
673
+
674
+ def open_dev_tools(
675
+ target_id: TargetID,
676
+ panel_id: typing.Optional[str] = None
677
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,TargetID]:
678
+ '''
679
+ Opens a DevTools window for the target.
680
+
681
+ **EXPERIMENTAL**
682
+
683
+ :param target_id: This can be the page or tab target ID.
684
+ :param panel_id: *(Optional)* The id of the panel we want DevTools to open initially. Currently supported panels are elements, console, network, sources, resources and performance.
685
+ :returns: The targetId of DevTools page target.
686
+ '''
687
+ params: T_JSON_DICT = dict()
688
+ params['targetId'] = target_id.to_json()
689
+ if panel_id is not None:
690
+ params['panelId'] = panel_id
691
+ cmd_dict: T_JSON_DICT = {
692
+ 'method': 'Target.openDevTools',
693
+ 'params': params,
694
+ }
695
+ json = yield cmd_dict
696
+ return TargetID.from_json(json['targetId'])
697
+
698
+
699
+ @event_class('Target.attachedToTarget')
700
+ @dataclass
701
+ class AttachedToTarget:
702
+ '''
703
+ **EXPERIMENTAL**
704
+
705
+ Issued when attached to target because of auto-attach or ``attachToTarget`` command.
706
+ '''
707
+ #: Identifier assigned to the session used to send/receive messages.
708
+ session_id: SessionID
709
+ target_info: TargetInfo
710
+ waiting_for_debugger: bool
711
+
712
+ @classmethod
713
+ def from_json(cls, json: T_JSON_DICT) -> AttachedToTarget:
714
+ return cls(
715
+ session_id=SessionID.from_json(json['sessionId']),
716
+ target_info=TargetInfo.from_json(json['targetInfo']),
717
+ waiting_for_debugger=bool(json['waitingForDebugger'])
718
+ )
719
+
720
+
721
+ @event_class('Target.detachedFromTarget')
722
+ @dataclass
723
+ class DetachedFromTarget:
724
+ '''
725
+ **EXPERIMENTAL**
726
+
727
+ Issued when detached from target for any reason (including ``detachFromTarget`` command). Can be
728
+ issued multiple times per target if multiple sessions have been attached to it.
729
+ '''
730
+ #: Detached session identifier.
731
+ session_id: SessionID
732
+ #: Deprecated.
733
+ target_id: typing.Optional[TargetID]
734
+
735
+ @classmethod
736
+ def from_json(cls, json: T_JSON_DICT) -> DetachedFromTarget:
737
+ return cls(
738
+ session_id=SessionID.from_json(json['sessionId']),
739
+ target_id=TargetID.from_json(json['targetId']) if json.get('targetId', None) is not None else None
740
+ )
741
+
742
+
743
+ @event_class('Target.receivedMessageFromTarget')
744
+ @dataclass
745
+ class ReceivedMessageFromTarget:
746
+ '''
747
+ Notifies about a new protocol message received from the session (as reported in
748
+ ``attachedToTarget`` event).
749
+ '''
750
+ #: Identifier of a session which sends a message.
751
+ session_id: SessionID
752
+ message: str
753
+ #: Deprecated.
754
+ target_id: typing.Optional[TargetID]
755
+
756
+ @classmethod
757
+ def from_json(cls, json: T_JSON_DICT) -> ReceivedMessageFromTarget:
758
+ return cls(
759
+ session_id=SessionID.from_json(json['sessionId']),
760
+ message=str(json['message']),
761
+ target_id=TargetID.from_json(json['targetId']) if json.get('targetId', None) is not None else None
762
+ )
763
+
764
+
765
+ @event_class('Target.targetCreated')
766
+ @dataclass
767
+ class TargetCreated:
768
+ '''
769
+ Issued when a possible inspection target is created.
770
+ '''
771
+ target_info: TargetInfo
772
+
773
+ @classmethod
774
+ def from_json(cls, json: T_JSON_DICT) -> TargetCreated:
775
+ return cls(
776
+ target_info=TargetInfo.from_json(json['targetInfo'])
777
+ )
778
+
779
+
780
+ @event_class('Target.targetDestroyed')
781
+ @dataclass
782
+ class TargetDestroyed:
783
+ '''
784
+ Issued when a target is destroyed.
785
+ '''
786
+ target_id: TargetID
787
+
788
+ @classmethod
789
+ def from_json(cls, json: T_JSON_DICT) -> TargetDestroyed:
790
+ return cls(
791
+ target_id=TargetID.from_json(json['targetId'])
792
+ )
793
+
794
+
795
+ @event_class('Target.targetCrashed')
796
+ @dataclass
797
+ class TargetCrashed:
798
+ '''
799
+ Issued when a target has crashed.
800
+ '''
801
+ target_id: TargetID
802
+ #: Termination status type.
803
+ status: str
804
+ #: Termination error code.
805
+ error_code: int
806
+
807
+ @classmethod
808
+ def from_json(cls, json: T_JSON_DICT) -> TargetCrashed:
809
+ return cls(
810
+ target_id=TargetID.from_json(json['targetId']),
811
+ status=str(json['status']),
812
+ error_code=int(json['errorCode'])
813
+ )
814
+
815
+
816
+ @event_class('Target.targetInfoChanged')
817
+ @dataclass
818
+ class TargetInfoChanged:
819
+ '''
820
+ Issued when some information about a target has changed. This only happens between
821
+ ``targetCreated`` and ``targetDestroyed``.
822
+ '''
823
+ target_info: TargetInfo
824
+
825
+ @classmethod
826
+ def from_json(cls, json: T_JSON_DICT) -> TargetInfoChanged:
827
+ return cls(
828
+ target_info=TargetInfo.from_json(json['targetInfo'])
829
+ )