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/dom.py ADDED
@@ -0,0 +1,2257 @@
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: DOM
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 network
15
+ from . import page
16
+ from . import runtime
17
+ from deprecated.sphinx import deprecated # type: ignore
18
+
19
+
20
+ class NodeId(int):
21
+ '''
22
+ Unique DOM node identifier.
23
+ '''
24
+ def to_json(self) -> int:
25
+ return self
26
+
27
+ @classmethod
28
+ def from_json(cls, json: int) -> NodeId:
29
+ return cls(json)
30
+
31
+ def __repr__(self):
32
+ return 'NodeId({})'.format(super().__repr__())
33
+
34
+
35
+ class BackendNodeId(int):
36
+ '''
37
+ Unique DOM node identifier used to reference a node that may not have been pushed to the
38
+ front-end.
39
+ '''
40
+ def to_json(self) -> int:
41
+ return self
42
+
43
+ @classmethod
44
+ def from_json(cls, json: int) -> BackendNodeId:
45
+ return cls(json)
46
+
47
+ def __repr__(self):
48
+ return 'BackendNodeId({})'.format(super().__repr__())
49
+
50
+
51
+ class StyleSheetId(str):
52
+ '''
53
+ Unique identifier for a CSS stylesheet.
54
+ '''
55
+ def to_json(self) -> str:
56
+ return self
57
+
58
+ @classmethod
59
+ def from_json(cls, json: str) -> StyleSheetId:
60
+ return cls(json)
61
+
62
+ def __repr__(self):
63
+ return 'StyleSheetId({})'.format(super().__repr__())
64
+
65
+
66
+ @dataclass
67
+ class BackendNode:
68
+ '''
69
+ Backend node with a friendly name.
70
+ '''
71
+ #: ``Node``'s nodeType.
72
+ node_type: int
73
+
74
+ #: ``Node``'s nodeName.
75
+ node_name: str
76
+
77
+ backend_node_id: BackendNodeId
78
+
79
+ def to_json(self) -> T_JSON_DICT:
80
+ json: T_JSON_DICT = dict()
81
+ json['nodeType'] = self.node_type
82
+ json['nodeName'] = self.node_name
83
+ json['backendNodeId'] = self.backend_node_id.to_json()
84
+ return json
85
+
86
+ @classmethod
87
+ def from_json(cls, json: T_JSON_DICT) -> BackendNode:
88
+ return cls(
89
+ node_type=int(json['nodeType']),
90
+ node_name=str(json['nodeName']),
91
+ backend_node_id=BackendNodeId.from_json(json['backendNodeId']),
92
+ )
93
+
94
+
95
+ class PseudoType(enum.Enum):
96
+ '''
97
+ Pseudo element type.
98
+ '''
99
+ FIRST_LINE = "first-line"
100
+ FIRST_LETTER = "first-letter"
101
+ CHECKMARK = "checkmark"
102
+ BEFORE = "before"
103
+ AFTER = "after"
104
+ EXPAND_ICON = "expand-icon"
105
+ PICKER_ICON = "picker-icon"
106
+ INTEREST_BUTTON = "interest-button"
107
+ MARKER = "marker"
108
+ BACKDROP = "backdrop"
109
+ COLUMN = "column"
110
+ SELECTION = "selection"
111
+ SEARCH_TEXT = "search-text"
112
+ TARGET_TEXT = "target-text"
113
+ SPELLING_ERROR = "spelling-error"
114
+ GRAMMAR_ERROR = "grammar-error"
115
+ HIGHLIGHT = "highlight"
116
+ FIRST_LINE_INHERITED = "first-line-inherited"
117
+ SCROLL_MARKER = "scroll-marker"
118
+ SCROLL_MARKER_GROUP = "scroll-marker-group"
119
+ SCROLL_BUTTON = "scroll-button"
120
+ SCROLLBAR = "scrollbar"
121
+ SCROLLBAR_THUMB = "scrollbar-thumb"
122
+ SCROLLBAR_BUTTON = "scrollbar-button"
123
+ SCROLLBAR_TRACK = "scrollbar-track"
124
+ SCROLLBAR_TRACK_PIECE = "scrollbar-track-piece"
125
+ SCROLLBAR_CORNER = "scrollbar-corner"
126
+ RESIZER = "resizer"
127
+ INPUT_LIST_BUTTON = "input-list-button"
128
+ VIEW_TRANSITION = "view-transition"
129
+ VIEW_TRANSITION_GROUP = "view-transition-group"
130
+ VIEW_TRANSITION_IMAGE_PAIR = "view-transition-image-pair"
131
+ VIEW_TRANSITION_GROUP_CHILDREN = "view-transition-group-children"
132
+ VIEW_TRANSITION_OLD = "view-transition-old"
133
+ VIEW_TRANSITION_NEW = "view-transition-new"
134
+ PLACEHOLDER = "placeholder"
135
+ FILE_SELECTOR_BUTTON = "file-selector-button"
136
+ DETAILS_CONTENT = "details-content"
137
+ PICKER = "picker"
138
+ PERMISSION_ICON = "permission-icon"
139
+ OVERSCROLL_AREA_PARENT = "overscroll-area-parent"
140
+
141
+ def to_json(self) -> str:
142
+ return self.value
143
+
144
+ @classmethod
145
+ def from_json(cls, json: str) -> PseudoType:
146
+ return cls(json)
147
+
148
+
149
+ class ShadowRootType(enum.Enum):
150
+ '''
151
+ Shadow root type.
152
+ '''
153
+ USER_AGENT = "user-agent"
154
+ OPEN_ = "open"
155
+ CLOSED = "closed"
156
+
157
+ def to_json(self) -> str:
158
+ return self.value
159
+
160
+ @classmethod
161
+ def from_json(cls, json: str) -> ShadowRootType:
162
+ return cls(json)
163
+
164
+
165
+ class CompatibilityMode(enum.Enum):
166
+ '''
167
+ Document compatibility mode.
168
+ '''
169
+ QUIRKS_MODE = "QuirksMode"
170
+ LIMITED_QUIRKS_MODE = "LimitedQuirksMode"
171
+ NO_QUIRKS_MODE = "NoQuirksMode"
172
+
173
+ def to_json(self) -> str:
174
+ return self.value
175
+
176
+ @classmethod
177
+ def from_json(cls, json: str) -> CompatibilityMode:
178
+ return cls(json)
179
+
180
+
181
+ class PhysicalAxes(enum.Enum):
182
+ '''
183
+ ContainerSelector physical axes
184
+ '''
185
+ HORIZONTAL = "Horizontal"
186
+ VERTICAL = "Vertical"
187
+ BOTH = "Both"
188
+
189
+ def to_json(self) -> str:
190
+ return self.value
191
+
192
+ @classmethod
193
+ def from_json(cls, json: str) -> PhysicalAxes:
194
+ return cls(json)
195
+
196
+
197
+ class LogicalAxes(enum.Enum):
198
+ '''
199
+ ContainerSelector logical axes
200
+ '''
201
+ INLINE = "Inline"
202
+ BLOCK = "Block"
203
+ BOTH = "Both"
204
+
205
+ def to_json(self) -> str:
206
+ return self.value
207
+
208
+ @classmethod
209
+ def from_json(cls, json: str) -> LogicalAxes:
210
+ return cls(json)
211
+
212
+
213
+ class ScrollOrientation(enum.Enum):
214
+ '''
215
+ Physical scroll orientation
216
+ '''
217
+ HORIZONTAL = "horizontal"
218
+ VERTICAL = "vertical"
219
+
220
+ def to_json(self) -> str:
221
+ return self.value
222
+
223
+ @classmethod
224
+ def from_json(cls, json: str) -> ScrollOrientation:
225
+ return cls(json)
226
+
227
+
228
+ @dataclass
229
+ class Node:
230
+ '''
231
+ DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes.
232
+ DOMNode is a base node mirror type.
233
+ '''
234
+ #: Node identifier that is passed into the rest of the DOM messages as the ``nodeId``. Backend
235
+ #: will only push node with given ``id`` once. It is aware of all requested nodes and will only
236
+ #: fire DOM events for nodes known to the client.
237
+ node_id: NodeId
238
+
239
+ #: The BackendNodeId for this node.
240
+ backend_node_id: BackendNodeId
241
+
242
+ #: ``Node``'s nodeType.
243
+ node_type: int
244
+
245
+ #: ``Node``'s nodeName.
246
+ node_name: str
247
+
248
+ #: ``Node``'s localName.
249
+ local_name: str
250
+
251
+ #: ``Node``'s nodeValue.
252
+ node_value: str
253
+
254
+ #: The id of the parent node if any.
255
+ parent_id: typing.Optional[NodeId] = None
256
+
257
+ #: Child count for ``Container`` nodes.
258
+ child_node_count: typing.Optional[int] = None
259
+
260
+ #: Child nodes of this node when requested with children.
261
+ children: typing.Optional[typing.List[Node]] = None
262
+
263
+ #: Attributes of the ``Element`` node in the form of flat array ``[name1, value1, name2, value2]``.
264
+ attributes: typing.Optional[typing.List[str]] = None
265
+
266
+ #: Document URL that ``Document`` or ``FrameOwner`` node points to.
267
+ document_url: typing.Optional[str] = None
268
+
269
+ #: Base URL that ``Document`` or ``FrameOwner`` node uses for URL completion.
270
+ base_url: typing.Optional[str] = None
271
+
272
+ #: ``DocumentType``'s publicId.
273
+ public_id: typing.Optional[str] = None
274
+
275
+ #: ``DocumentType``'s systemId.
276
+ system_id: typing.Optional[str] = None
277
+
278
+ #: ``DocumentType``'s internalSubset.
279
+ internal_subset: typing.Optional[str] = None
280
+
281
+ #: ``Document``'s XML version in case of XML documents.
282
+ xml_version: typing.Optional[str] = None
283
+
284
+ #: ``Attr``'s name.
285
+ name: typing.Optional[str] = None
286
+
287
+ #: ``Attr``'s value.
288
+ value: typing.Optional[str] = None
289
+
290
+ #: Pseudo element type for this node.
291
+ pseudo_type: typing.Optional[PseudoType] = None
292
+
293
+ #: Pseudo element identifier for this node. Only present if there is a
294
+ #: valid pseudoType.
295
+ pseudo_identifier: typing.Optional[str] = None
296
+
297
+ #: Shadow root type.
298
+ shadow_root_type: typing.Optional[ShadowRootType] = None
299
+
300
+ #: Frame ID for frame owner elements.
301
+ frame_id: typing.Optional[page.FrameId] = None
302
+
303
+ #: Content document for frame owner elements.
304
+ content_document: typing.Optional[Node] = None
305
+
306
+ #: Shadow root list for given element host.
307
+ shadow_roots: typing.Optional[typing.List[Node]] = None
308
+
309
+ #: Content document fragment for template elements.
310
+ template_content: typing.Optional[Node] = None
311
+
312
+ #: Pseudo elements associated with this node.
313
+ pseudo_elements: typing.Optional[typing.List[Node]] = None
314
+
315
+ #: Deprecated, as the HTML Imports API has been removed (crbug.com/937746).
316
+ #: This property used to return the imported document for the HTMLImport links.
317
+ #: The property is always undefined now.
318
+ imported_document: typing.Optional[Node] = None
319
+
320
+ #: Distributed nodes for given insertion point.
321
+ distributed_nodes: typing.Optional[typing.List[BackendNode]] = None
322
+
323
+ #: Whether the node is SVG.
324
+ is_svg: typing.Optional[bool] = None
325
+
326
+ compatibility_mode: typing.Optional[CompatibilityMode] = None
327
+
328
+ assigned_slot: typing.Optional[BackendNode] = None
329
+
330
+ is_scrollable: typing.Optional[bool] = None
331
+
332
+ affected_by_starting_styles: typing.Optional[bool] = None
333
+
334
+ adopted_style_sheets: typing.Optional[typing.List[StyleSheetId]] = None
335
+
336
+ ad_provenance: typing.Optional[network.AdProvenance] = None
337
+
338
+ def to_json(self) -> T_JSON_DICT:
339
+ json: T_JSON_DICT = dict()
340
+ json['nodeId'] = self.node_id.to_json()
341
+ json['backendNodeId'] = self.backend_node_id.to_json()
342
+ json['nodeType'] = self.node_type
343
+ json['nodeName'] = self.node_name
344
+ json['localName'] = self.local_name
345
+ json['nodeValue'] = self.node_value
346
+ if self.parent_id is not None:
347
+ json['parentId'] = self.parent_id.to_json()
348
+ if self.child_node_count is not None:
349
+ json['childNodeCount'] = self.child_node_count
350
+ if self.children is not None:
351
+ json['children'] = [i.to_json() for i in self.children]
352
+ if self.attributes is not None:
353
+ json['attributes'] = [i for i in self.attributes]
354
+ if self.document_url is not None:
355
+ json['documentURL'] = self.document_url
356
+ if self.base_url is not None:
357
+ json['baseURL'] = self.base_url
358
+ if self.public_id is not None:
359
+ json['publicId'] = self.public_id
360
+ if self.system_id is not None:
361
+ json['systemId'] = self.system_id
362
+ if self.internal_subset is not None:
363
+ json['internalSubset'] = self.internal_subset
364
+ if self.xml_version is not None:
365
+ json['xmlVersion'] = self.xml_version
366
+ if self.name is not None:
367
+ json['name'] = self.name
368
+ if self.value is not None:
369
+ json['value'] = self.value
370
+ if self.pseudo_type is not None:
371
+ json['pseudoType'] = self.pseudo_type.to_json()
372
+ if self.pseudo_identifier is not None:
373
+ json['pseudoIdentifier'] = self.pseudo_identifier
374
+ if self.shadow_root_type is not None:
375
+ json['shadowRootType'] = self.shadow_root_type.to_json()
376
+ if self.frame_id is not None:
377
+ json['frameId'] = self.frame_id.to_json()
378
+ if self.content_document is not None:
379
+ json['contentDocument'] = self.content_document.to_json()
380
+ if self.shadow_roots is not None:
381
+ json['shadowRoots'] = [i.to_json() for i in self.shadow_roots]
382
+ if self.template_content is not None:
383
+ json['templateContent'] = self.template_content.to_json()
384
+ if self.pseudo_elements is not None:
385
+ json['pseudoElements'] = [i.to_json() for i in self.pseudo_elements]
386
+ if self.imported_document is not None:
387
+ json['importedDocument'] = self.imported_document.to_json()
388
+ if self.distributed_nodes is not None:
389
+ json['distributedNodes'] = [i.to_json() for i in self.distributed_nodes]
390
+ if self.is_svg is not None:
391
+ json['isSVG'] = self.is_svg
392
+ if self.compatibility_mode is not None:
393
+ json['compatibilityMode'] = self.compatibility_mode.to_json()
394
+ if self.assigned_slot is not None:
395
+ json['assignedSlot'] = self.assigned_slot.to_json()
396
+ if self.is_scrollable is not None:
397
+ json['isScrollable'] = self.is_scrollable
398
+ if self.affected_by_starting_styles is not None:
399
+ json['affectedByStartingStyles'] = self.affected_by_starting_styles
400
+ if self.adopted_style_sheets is not None:
401
+ json['adoptedStyleSheets'] = [i.to_json() for i in self.adopted_style_sheets]
402
+ if self.ad_provenance is not None:
403
+ json['adProvenance'] = self.ad_provenance.to_json()
404
+ return json
405
+
406
+ @classmethod
407
+ def from_json(cls, json: T_JSON_DICT) -> Node:
408
+ return cls(
409
+ node_id=NodeId.from_json(json['nodeId']),
410
+ backend_node_id=BackendNodeId.from_json(json['backendNodeId']),
411
+ node_type=int(json['nodeType']),
412
+ node_name=str(json['nodeName']),
413
+ local_name=str(json['localName']),
414
+ node_value=str(json['nodeValue']),
415
+ parent_id=NodeId.from_json(json['parentId']) if json.get('parentId', None) is not None else None,
416
+ child_node_count=int(json['childNodeCount']) if json.get('childNodeCount', None) is not None else None,
417
+ children=[Node.from_json(i) for i in json['children']] if json.get('children', None) is not None else None,
418
+ attributes=[str(i) for i in json['attributes']] if json.get('attributes', None) is not None else None,
419
+ document_url=str(json['documentURL']) if json.get('documentURL', None) is not None else None,
420
+ base_url=str(json['baseURL']) if json.get('baseURL', None) is not None else None,
421
+ public_id=str(json['publicId']) if json.get('publicId', None) is not None else None,
422
+ system_id=str(json['systemId']) if json.get('systemId', None) is not None else None,
423
+ internal_subset=str(json['internalSubset']) if json.get('internalSubset', None) is not None else None,
424
+ xml_version=str(json['xmlVersion']) if json.get('xmlVersion', None) is not None else None,
425
+ name=str(json['name']) if json.get('name', None) is not None else None,
426
+ value=str(json['value']) if json.get('value', None) is not None else None,
427
+ pseudo_type=PseudoType.from_json(json['pseudoType']) if json.get('pseudoType', None) is not None else None,
428
+ pseudo_identifier=str(json['pseudoIdentifier']) if json.get('pseudoIdentifier', None) is not None else None,
429
+ shadow_root_type=ShadowRootType.from_json(json['shadowRootType']) if json.get('shadowRootType', None) is not None else None,
430
+ frame_id=page.FrameId.from_json(json['frameId']) if json.get('frameId', None) is not None else None,
431
+ content_document=Node.from_json(json['contentDocument']) if json.get('contentDocument', None) is not None else None,
432
+ shadow_roots=[Node.from_json(i) for i in json['shadowRoots']] if json.get('shadowRoots', None) is not None else None,
433
+ template_content=Node.from_json(json['templateContent']) if json.get('templateContent', None) is not None else None,
434
+ pseudo_elements=[Node.from_json(i) for i in json['pseudoElements']] if json.get('pseudoElements', None) is not None else None,
435
+ imported_document=Node.from_json(json['importedDocument']) if json.get('importedDocument', None) is not None else None,
436
+ distributed_nodes=[BackendNode.from_json(i) for i in json['distributedNodes']] if json.get('distributedNodes', None) is not None else None,
437
+ is_svg=bool(json['isSVG']) if json.get('isSVG', None) is not None else None,
438
+ compatibility_mode=CompatibilityMode.from_json(json['compatibilityMode']) if json.get('compatibilityMode', None) is not None else None,
439
+ assigned_slot=BackendNode.from_json(json['assignedSlot']) if json.get('assignedSlot', None) is not None else None,
440
+ is_scrollable=bool(json['isScrollable']) if json.get('isScrollable', None) is not None else None,
441
+ affected_by_starting_styles=bool(json['affectedByStartingStyles']) if json.get('affectedByStartingStyles', None) is not None else None,
442
+ adopted_style_sheets=[StyleSheetId.from_json(i) for i in json['adoptedStyleSheets']] if json.get('adoptedStyleSheets', None) is not None else None,
443
+ ad_provenance=network.AdProvenance.from_json(json['adProvenance']) if json.get('adProvenance', None) is not None else None,
444
+ )
445
+
446
+
447
+ @dataclass
448
+ class DetachedElementInfo:
449
+ '''
450
+ A structure to hold the top-level node of a detached tree and an array of its retained descendants.
451
+ '''
452
+ tree_node: Node
453
+
454
+ retained_node_ids: typing.List[NodeId]
455
+
456
+ def to_json(self) -> T_JSON_DICT:
457
+ json: T_JSON_DICT = dict()
458
+ json['treeNode'] = self.tree_node.to_json()
459
+ json['retainedNodeIds'] = [i.to_json() for i in self.retained_node_ids]
460
+ return json
461
+
462
+ @classmethod
463
+ def from_json(cls, json: T_JSON_DICT) -> DetachedElementInfo:
464
+ return cls(
465
+ tree_node=Node.from_json(json['treeNode']),
466
+ retained_node_ids=[NodeId.from_json(i) for i in json['retainedNodeIds']],
467
+ )
468
+
469
+
470
+ @dataclass
471
+ class RGBA:
472
+ '''
473
+ A structure holding an RGBA color.
474
+ '''
475
+ #: The red component, in the [0-255] range.
476
+ r: int
477
+
478
+ #: The green component, in the [0-255] range.
479
+ g: int
480
+
481
+ #: The blue component, in the [0-255] range.
482
+ b: int
483
+
484
+ #: The alpha component, in the [0-1] range (default: 1).
485
+ a: typing.Optional[float] = None
486
+
487
+ def to_json(self) -> T_JSON_DICT:
488
+ json: T_JSON_DICT = dict()
489
+ json['r'] = self.r
490
+ json['g'] = self.g
491
+ json['b'] = self.b
492
+ if self.a is not None:
493
+ json['a'] = self.a
494
+ return json
495
+
496
+ @classmethod
497
+ def from_json(cls, json: T_JSON_DICT) -> RGBA:
498
+ return cls(
499
+ r=int(json['r']),
500
+ g=int(json['g']),
501
+ b=int(json['b']),
502
+ a=float(json['a']) if json.get('a', None) is not None else None,
503
+ )
504
+
505
+
506
+ class Quad(list):
507
+ '''
508
+ An array of quad vertices, x immediately followed by y for each point, points clock-wise.
509
+ '''
510
+ def to_json(self) -> typing.List[float]:
511
+ return self
512
+
513
+ @classmethod
514
+ def from_json(cls, json: typing.List[float]) -> Quad:
515
+ return cls(json)
516
+
517
+ def __repr__(self):
518
+ return 'Quad({})'.format(super().__repr__())
519
+
520
+
521
+ @dataclass
522
+ class BoxModel:
523
+ '''
524
+ Box model.
525
+ '''
526
+ #: Content box
527
+ content: Quad
528
+
529
+ #: Padding box
530
+ padding: Quad
531
+
532
+ #: Border box
533
+ border: Quad
534
+
535
+ #: Margin box
536
+ margin: Quad
537
+
538
+ #: Node width
539
+ width: int
540
+
541
+ #: Node height
542
+ height: int
543
+
544
+ #: Shape outside coordinates
545
+ shape_outside: typing.Optional[ShapeOutsideInfo] = None
546
+
547
+ def to_json(self) -> T_JSON_DICT:
548
+ json: T_JSON_DICT = dict()
549
+ json['content'] = self.content.to_json()
550
+ json['padding'] = self.padding.to_json()
551
+ json['border'] = self.border.to_json()
552
+ json['margin'] = self.margin.to_json()
553
+ json['width'] = self.width
554
+ json['height'] = self.height
555
+ if self.shape_outside is not None:
556
+ json['shapeOutside'] = self.shape_outside.to_json()
557
+ return json
558
+
559
+ @classmethod
560
+ def from_json(cls, json: T_JSON_DICT) -> BoxModel:
561
+ return cls(
562
+ content=Quad.from_json(json['content']),
563
+ padding=Quad.from_json(json['padding']),
564
+ border=Quad.from_json(json['border']),
565
+ margin=Quad.from_json(json['margin']),
566
+ width=int(json['width']),
567
+ height=int(json['height']),
568
+ shape_outside=ShapeOutsideInfo.from_json(json['shapeOutside']) if json.get('shapeOutside', None) is not None else None,
569
+ )
570
+
571
+
572
+ @dataclass
573
+ class ShapeOutsideInfo:
574
+ '''
575
+ CSS Shape Outside details.
576
+ '''
577
+ #: Shape bounds
578
+ bounds: Quad
579
+
580
+ #: Shape coordinate details
581
+ shape: typing.List[typing.Any]
582
+
583
+ #: Margin shape bounds
584
+ margin_shape: typing.List[typing.Any]
585
+
586
+ def to_json(self) -> T_JSON_DICT:
587
+ json: T_JSON_DICT = dict()
588
+ json['bounds'] = self.bounds.to_json()
589
+ json['shape'] = [i for i in self.shape]
590
+ json['marginShape'] = [i for i in self.margin_shape]
591
+ return json
592
+
593
+ @classmethod
594
+ def from_json(cls, json: T_JSON_DICT) -> ShapeOutsideInfo:
595
+ return cls(
596
+ bounds=Quad.from_json(json['bounds']),
597
+ shape=[i for i in json['shape']],
598
+ margin_shape=[i for i in json['marginShape']],
599
+ )
600
+
601
+
602
+ @dataclass
603
+ class Rect:
604
+ '''
605
+ Rectangle.
606
+ '''
607
+ #: X coordinate
608
+ x: float
609
+
610
+ #: Y coordinate
611
+ y: float
612
+
613
+ #: Rectangle width
614
+ width: float
615
+
616
+ #: Rectangle height
617
+ height: float
618
+
619
+ def to_json(self) -> T_JSON_DICT:
620
+ json: T_JSON_DICT = dict()
621
+ json['x'] = self.x
622
+ json['y'] = self.y
623
+ json['width'] = self.width
624
+ json['height'] = self.height
625
+ return json
626
+
627
+ @classmethod
628
+ def from_json(cls, json: T_JSON_DICT) -> Rect:
629
+ return cls(
630
+ x=float(json['x']),
631
+ y=float(json['y']),
632
+ width=float(json['width']),
633
+ height=float(json['height']),
634
+ )
635
+
636
+
637
+ @dataclass
638
+ class CSSComputedStyleProperty:
639
+ #: Computed style property name.
640
+ name: str
641
+
642
+ #: Computed style property value.
643
+ value: str
644
+
645
+ def to_json(self) -> T_JSON_DICT:
646
+ json: T_JSON_DICT = dict()
647
+ json['name'] = self.name
648
+ json['value'] = self.value
649
+ return json
650
+
651
+ @classmethod
652
+ def from_json(cls, json: T_JSON_DICT) -> CSSComputedStyleProperty:
653
+ return cls(
654
+ name=str(json['name']),
655
+ value=str(json['value']),
656
+ )
657
+
658
+
659
+ def collect_class_names_from_subtree(
660
+ node_id: NodeId
661
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[str]]:
662
+ '''
663
+ Collects class names for the node with given id and all of it's child nodes.
664
+
665
+ **EXPERIMENTAL**
666
+
667
+ :param node_id: Id of the node to collect class names.
668
+ :returns: Class name list.
669
+ '''
670
+ params: T_JSON_DICT = dict()
671
+ params['nodeId'] = node_id.to_json()
672
+ cmd_dict: T_JSON_DICT = {
673
+ 'method': 'DOM.collectClassNamesFromSubtree',
674
+ 'params': params,
675
+ }
676
+ json = yield cmd_dict
677
+ return [str(i) for i in json['classNames']]
678
+
679
+
680
+ def copy_to(
681
+ node_id: NodeId,
682
+ target_node_id: NodeId,
683
+ insert_before_node_id: typing.Optional[NodeId] = None
684
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,NodeId]:
685
+ '''
686
+ Creates a deep copy of the specified node and places it into the target container before the
687
+ given anchor.
688
+
689
+ **EXPERIMENTAL**
690
+
691
+ :param node_id: Id of the node to copy.
692
+ :param target_node_id: Id of the element to drop the copy into.
693
+ :param insert_before_node_id: *(Optional)* Drop the copy before this node (if absent, the copy becomes the last child of ```targetNodeId```).
694
+ :returns: Id of the node clone.
695
+ '''
696
+ params: T_JSON_DICT = dict()
697
+ params['nodeId'] = node_id.to_json()
698
+ params['targetNodeId'] = target_node_id.to_json()
699
+ if insert_before_node_id is not None:
700
+ params['insertBeforeNodeId'] = insert_before_node_id.to_json()
701
+ cmd_dict: T_JSON_DICT = {
702
+ 'method': 'DOM.copyTo',
703
+ 'params': params,
704
+ }
705
+ json = yield cmd_dict
706
+ return NodeId.from_json(json['nodeId'])
707
+
708
+
709
+ def describe_node(
710
+ node_id: typing.Optional[NodeId] = None,
711
+ backend_node_id: typing.Optional[BackendNodeId] = None,
712
+ object_id: typing.Optional[runtime.RemoteObjectId] = None,
713
+ depth: typing.Optional[int] = None,
714
+ pierce: typing.Optional[bool] = None
715
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,Node]:
716
+ '''
717
+ Describes node given its id, does not require domain to be enabled. Does not start tracking any
718
+ objects, can be used for automation.
719
+
720
+ :param node_id: *(Optional)* Identifier of the node.
721
+ :param backend_node_id: *(Optional)* Identifier of the backend node.
722
+ :param object_id: *(Optional)* JavaScript object id of the node wrapper.
723
+ :param depth: *(Optional)* The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.
724
+ :param pierce: *(Optional)* Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
725
+ :returns: Node description.
726
+ '''
727
+ params: T_JSON_DICT = dict()
728
+ if node_id is not None:
729
+ params['nodeId'] = node_id.to_json()
730
+ if backend_node_id is not None:
731
+ params['backendNodeId'] = backend_node_id.to_json()
732
+ if object_id is not None:
733
+ params['objectId'] = object_id.to_json()
734
+ if depth is not None:
735
+ params['depth'] = depth
736
+ if pierce is not None:
737
+ params['pierce'] = pierce
738
+ cmd_dict: T_JSON_DICT = {
739
+ 'method': 'DOM.describeNode',
740
+ 'params': params,
741
+ }
742
+ json = yield cmd_dict
743
+ return Node.from_json(json['node'])
744
+
745
+
746
+ def scroll_into_view_if_needed(
747
+ node_id: typing.Optional[NodeId] = None,
748
+ backend_node_id: typing.Optional[BackendNodeId] = None,
749
+ object_id: typing.Optional[runtime.RemoteObjectId] = None,
750
+ rect: typing.Optional[Rect] = None
751
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
752
+ '''
753
+ Scrolls the specified rect of the given node into view if not already visible.
754
+ Note: exactly one between nodeId, backendNodeId and objectId should be passed
755
+ to identify the node.
756
+
757
+ :param node_id: *(Optional)* Identifier of the node.
758
+ :param backend_node_id: *(Optional)* Identifier of the backend node.
759
+ :param object_id: *(Optional)* JavaScript object id of the node wrapper.
760
+ :param rect: *(Optional)* The rect to be scrolled into view, relative to the node's border box, in CSS pixels. When omitted, center of the node will be used, similar to Element.scrollIntoView.
761
+ '''
762
+ params: T_JSON_DICT = dict()
763
+ if node_id is not None:
764
+ params['nodeId'] = node_id.to_json()
765
+ if backend_node_id is not None:
766
+ params['backendNodeId'] = backend_node_id.to_json()
767
+ if object_id is not None:
768
+ params['objectId'] = object_id.to_json()
769
+ if rect is not None:
770
+ params['rect'] = rect.to_json()
771
+ cmd_dict: T_JSON_DICT = {
772
+ 'method': 'DOM.scrollIntoViewIfNeeded',
773
+ 'params': params,
774
+ }
775
+ json = yield cmd_dict
776
+
777
+
778
+ def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
779
+ '''
780
+ Disables DOM agent for the given page.
781
+ '''
782
+ cmd_dict: T_JSON_DICT = {
783
+ 'method': 'DOM.disable',
784
+ }
785
+ json = yield cmd_dict
786
+
787
+
788
+ def discard_search_results(
789
+ search_id: str
790
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
791
+ '''
792
+ Discards search results from the session with the given id. ``getSearchResults`` should no longer
793
+ be called for that search.
794
+
795
+ **EXPERIMENTAL**
796
+
797
+ :param search_id: Unique search session identifier.
798
+ '''
799
+ params: T_JSON_DICT = dict()
800
+ params['searchId'] = search_id
801
+ cmd_dict: T_JSON_DICT = {
802
+ 'method': 'DOM.discardSearchResults',
803
+ 'params': params,
804
+ }
805
+ json = yield cmd_dict
806
+
807
+
808
+ def enable(
809
+ include_whitespace: typing.Optional[str] = None
810
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
811
+ '''
812
+ Enables DOM agent for the given page.
813
+
814
+ :param include_whitespace: **(EXPERIMENTAL)** *(Optional)* Whether to include whitespaces in the children array of returned Nodes.
815
+ '''
816
+ params: T_JSON_DICT = dict()
817
+ if include_whitespace is not None:
818
+ params['includeWhitespace'] = include_whitespace
819
+ cmd_dict: T_JSON_DICT = {
820
+ 'method': 'DOM.enable',
821
+ 'params': params,
822
+ }
823
+ json = yield cmd_dict
824
+
825
+
826
+ def focus(
827
+ node_id: typing.Optional[NodeId] = None,
828
+ backend_node_id: typing.Optional[BackendNodeId] = None,
829
+ object_id: typing.Optional[runtime.RemoteObjectId] = None
830
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
831
+ '''
832
+ Focuses the given element.
833
+
834
+ :param node_id: *(Optional)* Identifier of the node.
835
+ :param backend_node_id: *(Optional)* Identifier of the backend node.
836
+ :param object_id: *(Optional)* JavaScript object id of the node wrapper.
837
+ '''
838
+ params: T_JSON_DICT = dict()
839
+ if node_id is not None:
840
+ params['nodeId'] = node_id.to_json()
841
+ if backend_node_id is not None:
842
+ params['backendNodeId'] = backend_node_id.to_json()
843
+ if object_id is not None:
844
+ params['objectId'] = object_id.to_json()
845
+ cmd_dict: T_JSON_DICT = {
846
+ 'method': 'DOM.focus',
847
+ 'params': params,
848
+ }
849
+ json = yield cmd_dict
850
+
851
+
852
+ def get_attributes(
853
+ node_id: NodeId
854
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[str]]:
855
+ '''
856
+ Returns attributes for the specified node.
857
+
858
+ :param node_id: Id of the node to retrieve attributes for.
859
+ :returns: An interleaved array of node attribute names and values.
860
+ '''
861
+ params: T_JSON_DICT = dict()
862
+ params['nodeId'] = node_id.to_json()
863
+ cmd_dict: T_JSON_DICT = {
864
+ 'method': 'DOM.getAttributes',
865
+ 'params': params,
866
+ }
867
+ json = yield cmd_dict
868
+ return [str(i) for i in json['attributes']]
869
+
870
+
871
+ def get_box_model(
872
+ node_id: typing.Optional[NodeId] = None,
873
+ backend_node_id: typing.Optional[BackendNodeId] = None,
874
+ object_id: typing.Optional[runtime.RemoteObjectId] = None
875
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,BoxModel]:
876
+ '''
877
+ Returns boxes for the given node.
878
+
879
+ :param node_id: *(Optional)* Identifier of the node.
880
+ :param backend_node_id: *(Optional)* Identifier of the backend node.
881
+ :param object_id: *(Optional)* JavaScript object id of the node wrapper.
882
+ :returns: Box model for the node.
883
+ '''
884
+ params: T_JSON_DICT = dict()
885
+ if node_id is not None:
886
+ params['nodeId'] = node_id.to_json()
887
+ if backend_node_id is not None:
888
+ params['backendNodeId'] = backend_node_id.to_json()
889
+ if object_id is not None:
890
+ params['objectId'] = object_id.to_json()
891
+ cmd_dict: T_JSON_DICT = {
892
+ 'method': 'DOM.getBoxModel',
893
+ 'params': params,
894
+ }
895
+ json = yield cmd_dict
896
+ return BoxModel.from_json(json['model'])
897
+
898
+
899
+ def get_content_quads(
900
+ node_id: typing.Optional[NodeId] = None,
901
+ backend_node_id: typing.Optional[BackendNodeId] = None,
902
+ object_id: typing.Optional[runtime.RemoteObjectId] = None
903
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[Quad]]:
904
+ '''
905
+ Returns quads that describe node position on the page. This method
906
+ might return multiple quads for inline nodes.
907
+
908
+ **EXPERIMENTAL**
909
+
910
+ :param node_id: *(Optional)* Identifier of the node.
911
+ :param backend_node_id: *(Optional)* Identifier of the backend node.
912
+ :param object_id: *(Optional)* JavaScript object id of the node wrapper.
913
+ :returns: Quads that describe node layout relative to viewport.
914
+ '''
915
+ params: T_JSON_DICT = dict()
916
+ if node_id is not None:
917
+ params['nodeId'] = node_id.to_json()
918
+ if backend_node_id is not None:
919
+ params['backendNodeId'] = backend_node_id.to_json()
920
+ if object_id is not None:
921
+ params['objectId'] = object_id.to_json()
922
+ cmd_dict: T_JSON_DICT = {
923
+ 'method': 'DOM.getContentQuads',
924
+ 'params': params,
925
+ }
926
+ json = yield cmd_dict
927
+ return [Quad.from_json(i) for i in json['quads']]
928
+
929
+
930
+ def get_document(
931
+ depth: typing.Optional[int] = None,
932
+ pierce: typing.Optional[bool] = None
933
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,Node]:
934
+ '''
935
+ Returns the root DOM node (and optionally the subtree) to the caller.
936
+ Implicitly enables the DOM domain events for the current target.
937
+
938
+ :param depth: *(Optional)* The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.
939
+ :param pierce: *(Optional)* Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
940
+ :returns: Resulting node.
941
+ '''
942
+ params: T_JSON_DICT = dict()
943
+ if depth is not None:
944
+ params['depth'] = depth
945
+ if pierce is not None:
946
+ params['pierce'] = pierce
947
+ cmd_dict: T_JSON_DICT = {
948
+ 'method': 'DOM.getDocument',
949
+ 'params': params,
950
+ }
951
+ json = yield cmd_dict
952
+ return Node.from_json(json['root'])
953
+
954
+
955
+ @deprecated(version="1.3")
956
+ def get_flattened_document(
957
+ depth: typing.Optional[int] = None,
958
+ pierce: typing.Optional[bool] = None
959
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[Node]]:
960
+ '''
961
+ Returns the root DOM node (and optionally the subtree) to the caller.
962
+ Deprecated, as it is not designed to work well with the rest of the DOM agent.
963
+ Use DOMSnapshot.captureSnapshot instead.
964
+
965
+ .. deprecated:: 1.3
966
+
967
+ :param depth: *(Optional)* The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.
968
+ :param pierce: *(Optional)* Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
969
+ :returns: Resulting node.
970
+ '''
971
+ params: T_JSON_DICT = dict()
972
+ if depth is not None:
973
+ params['depth'] = depth
974
+ if pierce is not None:
975
+ params['pierce'] = pierce
976
+ cmd_dict: T_JSON_DICT = {
977
+ 'method': 'DOM.getFlattenedDocument',
978
+ 'params': params,
979
+ }
980
+ json = yield cmd_dict
981
+ return [Node.from_json(i) for i in json['nodes']]
982
+
983
+
984
+ def get_nodes_for_subtree_by_style(
985
+ node_id: NodeId,
986
+ computed_styles: typing.List[CSSComputedStyleProperty],
987
+ pierce: typing.Optional[bool] = None
988
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[NodeId]]:
989
+ '''
990
+ Finds nodes with a given computed style in a subtree.
991
+
992
+ **EXPERIMENTAL**
993
+
994
+ :param node_id: Node ID pointing to the root of a subtree.
995
+ :param computed_styles: The style to filter nodes by (includes nodes if any of properties matches).
996
+ :param pierce: *(Optional)* Whether or not iframes and shadow roots in the same target should be traversed when returning the results (default is false).
997
+ :returns: Resulting nodes.
998
+ '''
999
+ params: T_JSON_DICT = dict()
1000
+ params['nodeId'] = node_id.to_json()
1001
+ params['computedStyles'] = [i.to_json() for i in computed_styles]
1002
+ if pierce is not None:
1003
+ params['pierce'] = pierce
1004
+ cmd_dict: T_JSON_DICT = {
1005
+ 'method': 'DOM.getNodesForSubtreeByStyle',
1006
+ 'params': params,
1007
+ }
1008
+ json = yield cmd_dict
1009
+ return [NodeId.from_json(i) for i in json['nodeIds']]
1010
+
1011
+
1012
+ def get_node_for_location(
1013
+ x: int,
1014
+ y: int,
1015
+ include_user_agent_shadow_dom: typing.Optional[bool] = None,
1016
+ ignore_pointer_events_none: typing.Optional[bool] = None
1017
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[BackendNodeId, page.FrameId, typing.Optional[NodeId]]]:
1018
+ '''
1019
+ Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is
1020
+ either returned or not.
1021
+
1022
+ :param x: X coordinate.
1023
+ :param y: Y coordinate.
1024
+ :param include_user_agent_shadow_dom: *(Optional)* False to skip to the nearest non-UA shadow root ancestor (default: false).
1025
+ :param ignore_pointer_events_none: *(Optional)* Whether to ignore pointer-events: none on elements and hit test them.
1026
+ :returns: A tuple with the following items:
1027
+
1028
+ 0. **backendNodeId** - Resulting node.
1029
+ 1. **frameId** - Frame this node belongs to.
1030
+ 2. **nodeId** - *(Optional)* Id of the node at given coordinates, only when enabled and requested document.
1031
+ '''
1032
+ params: T_JSON_DICT = dict()
1033
+ params['x'] = x
1034
+ params['y'] = y
1035
+ if include_user_agent_shadow_dom is not None:
1036
+ params['includeUserAgentShadowDOM'] = include_user_agent_shadow_dom
1037
+ if ignore_pointer_events_none is not None:
1038
+ params['ignorePointerEventsNone'] = ignore_pointer_events_none
1039
+ cmd_dict: T_JSON_DICT = {
1040
+ 'method': 'DOM.getNodeForLocation',
1041
+ 'params': params,
1042
+ }
1043
+ json = yield cmd_dict
1044
+ return (
1045
+ BackendNodeId.from_json(json['backendNodeId']),
1046
+ page.FrameId.from_json(json['frameId']),
1047
+ NodeId.from_json(json['nodeId']) if json.get('nodeId', None) is not None else None
1048
+ )
1049
+
1050
+
1051
+ def get_outer_html(
1052
+ node_id: typing.Optional[NodeId] = None,
1053
+ backend_node_id: typing.Optional[BackendNodeId] = None,
1054
+ object_id: typing.Optional[runtime.RemoteObjectId] = None,
1055
+ include_shadow_dom: typing.Optional[bool] = None
1056
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
1057
+ '''
1058
+ Returns node's HTML markup.
1059
+
1060
+ :param node_id: *(Optional)* Identifier of the node.
1061
+ :param backend_node_id: *(Optional)* Identifier of the backend node.
1062
+ :param object_id: *(Optional)* JavaScript object id of the node wrapper.
1063
+ :param include_shadow_dom: **(EXPERIMENTAL)** *(Optional)* Include all shadow roots. Equals to false if not specified.
1064
+ :returns: Outer HTML markup.
1065
+ '''
1066
+ params: T_JSON_DICT = dict()
1067
+ if node_id is not None:
1068
+ params['nodeId'] = node_id.to_json()
1069
+ if backend_node_id is not None:
1070
+ params['backendNodeId'] = backend_node_id.to_json()
1071
+ if object_id is not None:
1072
+ params['objectId'] = object_id.to_json()
1073
+ if include_shadow_dom is not None:
1074
+ params['includeShadowDOM'] = include_shadow_dom
1075
+ cmd_dict: T_JSON_DICT = {
1076
+ 'method': 'DOM.getOuterHTML',
1077
+ 'params': params,
1078
+ }
1079
+ json = yield cmd_dict
1080
+ return str(json['outerHTML'])
1081
+
1082
+
1083
+ def get_relayout_boundary(
1084
+ node_id: NodeId
1085
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,NodeId]:
1086
+ '''
1087
+ Returns the id of the nearest ancestor that is a relayout boundary.
1088
+
1089
+ **EXPERIMENTAL**
1090
+
1091
+ :param node_id: Id of the node.
1092
+ :returns: Relayout boundary node id for the given node.
1093
+ '''
1094
+ params: T_JSON_DICT = dict()
1095
+ params['nodeId'] = node_id.to_json()
1096
+ cmd_dict: T_JSON_DICT = {
1097
+ 'method': 'DOM.getRelayoutBoundary',
1098
+ 'params': params,
1099
+ }
1100
+ json = yield cmd_dict
1101
+ return NodeId.from_json(json['nodeId'])
1102
+
1103
+
1104
+ def get_search_results(
1105
+ search_id: str,
1106
+ from_index: int,
1107
+ to_index: int
1108
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[NodeId]]:
1109
+ '''
1110
+ Returns search results from given ``fromIndex`` to given ``toIndex`` from the search with the given
1111
+ identifier.
1112
+
1113
+ **EXPERIMENTAL**
1114
+
1115
+ :param search_id: Unique search session identifier.
1116
+ :param from_index: Start index of the search result to be returned.
1117
+ :param to_index: End index of the search result to be returned.
1118
+ :returns: Ids of the search result nodes.
1119
+ '''
1120
+ params: T_JSON_DICT = dict()
1121
+ params['searchId'] = search_id
1122
+ params['fromIndex'] = from_index
1123
+ params['toIndex'] = to_index
1124
+ cmd_dict: T_JSON_DICT = {
1125
+ 'method': 'DOM.getSearchResults',
1126
+ 'params': params,
1127
+ }
1128
+ json = yield cmd_dict
1129
+ return [NodeId.from_json(i) for i in json['nodeIds']]
1130
+
1131
+
1132
+ def hide_highlight() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1133
+ '''
1134
+ Hides any highlight.
1135
+ '''
1136
+ cmd_dict: T_JSON_DICT = {
1137
+ 'method': 'DOM.hideHighlight',
1138
+ }
1139
+ json = yield cmd_dict
1140
+
1141
+
1142
+ def highlight_node() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1143
+ '''
1144
+ Highlights DOM node.
1145
+ '''
1146
+ cmd_dict: T_JSON_DICT = {
1147
+ 'method': 'DOM.highlightNode',
1148
+ }
1149
+ json = yield cmd_dict
1150
+
1151
+
1152
+ def highlight_rect() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1153
+ '''
1154
+ Highlights given rectangle.
1155
+ '''
1156
+ cmd_dict: T_JSON_DICT = {
1157
+ 'method': 'DOM.highlightRect',
1158
+ }
1159
+ json = yield cmd_dict
1160
+
1161
+
1162
+ def mark_undoable_state() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1163
+ '''
1164
+ Marks last undoable state.
1165
+
1166
+ **EXPERIMENTAL**
1167
+ '''
1168
+ cmd_dict: T_JSON_DICT = {
1169
+ 'method': 'DOM.markUndoableState',
1170
+ }
1171
+ json = yield cmd_dict
1172
+
1173
+
1174
+ def move_to(
1175
+ node_id: NodeId,
1176
+ target_node_id: NodeId,
1177
+ insert_before_node_id: typing.Optional[NodeId] = None
1178
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,NodeId]:
1179
+ '''
1180
+ Moves node into the new container, places it before the given anchor.
1181
+
1182
+ :param node_id: Id of the node to move.
1183
+ :param target_node_id: Id of the element to drop the moved node into.
1184
+ :param insert_before_node_id: *(Optional)* Drop node before this one (if absent, the moved node becomes the last child of ```targetNodeId```).
1185
+ :returns: New id of the moved node.
1186
+ '''
1187
+ params: T_JSON_DICT = dict()
1188
+ params['nodeId'] = node_id.to_json()
1189
+ params['targetNodeId'] = target_node_id.to_json()
1190
+ if insert_before_node_id is not None:
1191
+ params['insertBeforeNodeId'] = insert_before_node_id.to_json()
1192
+ cmd_dict: T_JSON_DICT = {
1193
+ 'method': 'DOM.moveTo',
1194
+ 'params': params,
1195
+ }
1196
+ json = yield cmd_dict
1197
+ return NodeId.from_json(json['nodeId'])
1198
+
1199
+
1200
+ def perform_search(
1201
+ query: str,
1202
+ include_user_agent_shadow_dom: typing.Optional[bool] = None
1203
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[str, int]]:
1204
+ '''
1205
+ Searches for a given string in the DOM tree. Use ``getSearchResults`` to access search results or
1206
+ ``cancelSearch`` to end this search session.
1207
+
1208
+ **EXPERIMENTAL**
1209
+
1210
+ :param query: Plain text or query selector or XPath search query.
1211
+ :param include_user_agent_shadow_dom: *(Optional)* True to search in user agent shadow DOM.
1212
+ :returns: A tuple with the following items:
1213
+
1214
+ 0. **searchId** - Unique search session identifier.
1215
+ 1. **resultCount** - Number of search results.
1216
+ '''
1217
+ params: T_JSON_DICT = dict()
1218
+ params['query'] = query
1219
+ if include_user_agent_shadow_dom is not None:
1220
+ params['includeUserAgentShadowDOM'] = include_user_agent_shadow_dom
1221
+ cmd_dict: T_JSON_DICT = {
1222
+ 'method': 'DOM.performSearch',
1223
+ 'params': params,
1224
+ }
1225
+ json = yield cmd_dict
1226
+ return (
1227
+ str(json['searchId']),
1228
+ int(json['resultCount'])
1229
+ )
1230
+
1231
+
1232
+ def push_node_by_path_to_frontend(
1233
+ path: str
1234
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,NodeId]:
1235
+ '''
1236
+ Requests that the node is sent to the caller given its path. // FIXME, use XPath
1237
+
1238
+ **EXPERIMENTAL**
1239
+
1240
+ :param path: Path to node in the proprietary format.
1241
+ :returns: Id of the node for given path.
1242
+ '''
1243
+ params: T_JSON_DICT = dict()
1244
+ params['path'] = path
1245
+ cmd_dict: T_JSON_DICT = {
1246
+ 'method': 'DOM.pushNodeByPathToFrontend',
1247
+ 'params': params,
1248
+ }
1249
+ json = yield cmd_dict
1250
+ return NodeId.from_json(json['nodeId'])
1251
+
1252
+
1253
+ def push_nodes_by_backend_ids_to_frontend(
1254
+ backend_node_ids: typing.List[BackendNodeId]
1255
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[NodeId]]:
1256
+ '''
1257
+ Requests that a batch of nodes is sent to the caller given their backend node ids.
1258
+
1259
+ **EXPERIMENTAL**
1260
+
1261
+ :param backend_node_ids: The array of backend node ids.
1262
+ :returns: The array of ids of pushed nodes that correspond to the backend ids specified in backendNodeIds.
1263
+ '''
1264
+ params: T_JSON_DICT = dict()
1265
+ params['backendNodeIds'] = [i.to_json() for i in backend_node_ids]
1266
+ cmd_dict: T_JSON_DICT = {
1267
+ 'method': 'DOM.pushNodesByBackendIdsToFrontend',
1268
+ 'params': params,
1269
+ }
1270
+ json = yield cmd_dict
1271
+ return [NodeId.from_json(i) for i in json['nodeIds']]
1272
+
1273
+
1274
+ def query_selector(
1275
+ node_id: NodeId,
1276
+ selector: str
1277
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,NodeId]:
1278
+ '''
1279
+ Executes ``querySelector`` on a given node.
1280
+
1281
+ :param node_id: Id of the node to query upon.
1282
+ :param selector: Selector string.
1283
+ :returns: Query selector result.
1284
+ '''
1285
+ params: T_JSON_DICT = dict()
1286
+ params['nodeId'] = node_id.to_json()
1287
+ params['selector'] = selector
1288
+ cmd_dict: T_JSON_DICT = {
1289
+ 'method': 'DOM.querySelector',
1290
+ 'params': params,
1291
+ }
1292
+ json = yield cmd_dict
1293
+ return NodeId.from_json(json['nodeId'])
1294
+
1295
+
1296
+ def query_selector_all(
1297
+ node_id: NodeId,
1298
+ selector: str
1299
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[NodeId]]:
1300
+ '''
1301
+ Executes ``querySelectorAll`` on a given node.
1302
+
1303
+ :param node_id: Id of the node to query upon.
1304
+ :param selector: Selector string.
1305
+ :returns: Query selector result.
1306
+ '''
1307
+ params: T_JSON_DICT = dict()
1308
+ params['nodeId'] = node_id.to_json()
1309
+ params['selector'] = selector
1310
+ cmd_dict: T_JSON_DICT = {
1311
+ 'method': 'DOM.querySelectorAll',
1312
+ 'params': params,
1313
+ }
1314
+ json = yield cmd_dict
1315
+ return [NodeId.from_json(i) for i in json['nodeIds']]
1316
+
1317
+
1318
+ def get_top_layer_elements() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[NodeId]]:
1319
+ '''
1320
+ Returns NodeIds of current top layer elements.
1321
+ Top layer is rendered closest to the user within a viewport, therefore its elements always
1322
+ appear on top of all other content.
1323
+
1324
+ **EXPERIMENTAL**
1325
+
1326
+ :returns: NodeIds of top layer elements
1327
+ '''
1328
+ cmd_dict: T_JSON_DICT = {
1329
+ 'method': 'DOM.getTopLayerElements',
1330
+ }
1331
+ json = yield cmd_dict
1332
+ return [NodeId.from_json(i) for i in json['nodeIds']]
1333
+
1334
+
1335
+ def get_element_by_relation(
1336
+ node_id: NodeId,
1337
+ relation: str
1338
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,NodeId]:
1339
+ '''
1340
+ Returns the NodeId of the matched element according to certain relations.
1341
+
1342
+ **EXPERIMENTAL**
1343
+
1344
+ :param node_id: Id of the node from which to query the relation.
1345
+ :param relation: Type of relation to get.
1346
+ :returns: NodeId of the element matching the queried relation.
1347
+ '''
1348
+ params: T_JSON_DICT = dict()
1349
+ params['nodeId'] = node_id.to_json()
1350
+ params['relation'] = relation
1351
+ cmd_dict: T_JSON_DICT = {
1352
+ 'method': 'DOM.getElementByRelation',
1353
+ 'params': params,
1354
+ }
1355
+ json = yield cmd_dict
1356
+ return NodeId.from_json(json['nodeId'])
1357
+
1358
+
1359
+ def redo() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1360
+ '''
1361
+ Re-does the last undone action.
1362
+
1363
+ **EXPERIMENTAL**
1364
+ '''
1365
+ cmd_dict: T_JSON_DICT = {
1366
+ 'method': 'DOM.redo',
1367
+ }
1368
+ json = yield cmd_dict
1369
+
1370
+
1371
+ def remove_attribute(
1372
+ node_id: NodeId,
1373
+ name: str
1374
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1375
+ '''
1376
+ Removes attribute with given name from an element with given id.
1377
+
1378
+ :param node_id: Id of the element to remove attribute from.
1379
+ :param name: Name of the attribute to remove.
1380
+ '''
1381
+ params: T_JSON_DICT = dict()
1382
+ params['nodeId'] = node_id.to_json()
1383
+ params['name'] = name
1384
+ cmd_dict: T_JSON_DICT = {
1385
+ 'method': 'DOM.removeAttribute',
1386
+ 'params': params,
1387
+ }
1388
+ json = yield cmd_dict
1389
+
1390
+
1391
+ def remove_node(
1392
+ node_id: NodeId
1393
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1394
+ '''
1395
+ Removes node with given id.
1396
+
1397
+ :param node_id: Id of the node to remove.
1398
+ '''
1399
+ params: T_JSON_DICT = dict()
1400
+ params['nodeId'] = node_id.to_json()
1401
+ cmd_dict: T_JSON_DICT = {
1402
+ 'method': 'DOM.removeNode',
1403
+ 'params': params,
1404
+ }
1405
+ json = yield cmd_dict
1406
+
1407
+
1408
+ def request_child_nodes(
1409
+ node_id: NodeId,
1410
+ depth: typing.Optional[int] = None,
1411
+ pierce: typing.Optional[bool] = None
1412
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1413
+ '''
1414
+ Requests that children of the node with given id are returned to the caller in form of
1415
+ ``setChildNodes`` events where not only immediate children are retrieved, but all children down to
1416
+ the specified depth.
1417
+
1418
+ :param node_id: Id of the node to get children for.
1419
+ :param depth: *(Optional)* The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.
1420
+ :param pierce: *(Optional)* Whether or not iframes and shadow roots should be traversed when returning the sub-tree (default is false).
1421
+ '''
1422
+ params: T_JSON_DICT = dict()
1423
+ params['nodeId'] = node_id.to_json()
1424
+ if depth is not None:
1425
+ params['depth'] = depth
1426
+ if pierce is not None:
1427
+ params['pierce'] = pierce
1428
+ cmd_dict: T_JSON_DICT = {
1429
+ 'method': 'DOM.requestChildNodes',
1430
+ 'params': params,
1431
+ }
1432
+ json = yield cmd_dict
1433
+
1434
+
1435
+ def request_node(
1436
+ object_id: runtime.RemoteObjectId
1437
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,NodeId]:
1438
+ '''
1439
+ Requests that the node is sent to the caller given the JavaScript node object reference. All
1440
+ nodes that form the path from the node to the root are also sent to the client as a series of
1441
+ ``setChildNodes`` notifications.
1442
+
1443
+ :param object_id: JavaScript object id to convert into node.
1444
+ :returns: Node id for given object.
1445
+ '''
1446
+ params: T_JSON_DICT = dict()
1447
+ params['objectId'] = object_id.to_json()
1448
+ cmd_dict: T_JSON_DICT = {
1449
+ 'method': 'DOM.requestNode',
1450
+ 'params': params,
1451
+ }
1452
+ json = yield cmd_dict
1453
+ return NodeId.from_json(json['nodeId'])
1454
+
1455
+
1456
+ def resolve_node(
1457
+ node_id: typing.Optional[NodeId] = None,
1458
+ backend_node_id: typing.Optional[BackendNodeId] = None,
1459
+ object_group: typing.Optional[str] = None,
1460
+ execution_context_id: typing.Optional[runtime.ExecutionContextId] = None
1461
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,runtime.RemoteObject]:
1462
+ '''
1463
+ Resolves the JavaScript node object for a given NodeId or BackendNodeId.
1464
+
1465
+ :param node_id: *(Optional)* Id of the node to resolve.
1466
+ :param backend_node_id: *(Optional)* Backend identifier of the node to resolve.
1467
+ :param object_group: *(Optional)* Symbolic group name that can be used to release multiple objects.
1468
+ :param execution_context_id: *(Optional)* Execution context in which to resolve the node.
1469
+ :returns: JavaScript object wrapper for given node.
1470
+ '''
1471
+ params: T_JSON_DICT = dict()
1472
+ if node_id is not None:
1473
+ params['nodeId'] = node_id.to_json()
1474
+ if backend_node_id is not None:
1475
+ params['backendNodeId'] = backend_node_id.to_json()
1476
+ if object_group is not None:
1477
+ params['objectGroup'] = object_group
1478
+ if execution_context_id is not None:
1479
+ params['executionContextId'] = execution_context_id.to_json()
1480
+ cmd_dict: T_JSON_DICT = {
1481
+ 'method': 'DOM.resolveNode',
1482
+ 'params': params,
1483
+ }
1484
+ json = yield cmd_dict
1485
+ return runtime.RemoteObject.from_json(json['object'])
1486
+
1487
+
1488
+ def set_attribute_value(
1489
+ node_id: NodeId,
1490
+ name: str,
1491
+ value: str
1492
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1493
+ '''
1494
+ Sets attribute for an element with given id.
1495
+
1496
+ :param node_id: Id of the element to set attribute for.
1497
+ :param name: Attribute name.
1498
+ :param value: Attribute value.
1499
+ '''
1500
+ params: T_JSON_DICT = dict()
1501
+ params['nodeId'] = node_id.to_json()
1502
+ params['name'] = name
1503
+ params['value'] = value
1504
+ cmd_dict: T_JSON_DICT = {
1505
+ 'method': 'DOM.setAttributeValue',
1506
+ 'params': params,
1507
+ }
1508
+ json = yield cmd_dict
1509
+
1510
+
1511
+ def set_attributes_as_text(
1512
+ node_id: NodeId,
1513
+ text: str,
1514
+ name: typing.Optional[str] = None
1515
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1516
+ '''
1517
+ Sets attributes on element with given id. This method is useful when user edits some existing
1518
+ attribute value and types in several attribute name/value pairs.
1519
+
1520
+ :param node_id: Id of the element to set attributes for.
1521
+ :param text: Text with a number of attributes. Will parse this text using HTML parser.
1522
+ :param name: *(Optional)* Attribute name to replace with new attributes derived from text in case text parsed successfully.
1523
+ '''
1524
+ params: T_JSON_DICT = dict()
1525
+ params['nodeId'] = node_id.to_json()
1526
+ params['text'] = text
1527
+ if name is not None:
1528
+ params['name'] = name
1529
+ cmd_dict: T_JSON_DICT = {
1530
+ 'method': 'DOM.setAttributesAsText',
1531
+ 'params': params,
1532
+ }
1533
+ json = yield cmd_dict
1534
+
1535
+
1536
+ def set_file_input_files(
1537
+ files: typing.List[str],
1538
+ node_id: typing.Optional[NodeId] = None,
1539
+ backend_node_id: typing.Optional[BackendNodeId] = None,
1540
+ object_id: typing.Optional[runtime.RemoteObjectId] = None
1541
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1542
+ '''
1543
+ Sets files for the given file input element.
1544
+
1545
+ :param files: Array of file paths to set.
1546
+ :param node_id: *(Optional)* Identifier of the node.
1547
+ :param backend_node_id: *(Optional)* Identifier of the backend node.
1548
+ :param object_id: *(Optional)* JavaScript object id of the node wrapper.
1549
+ '''
1550
+ params: T_JSON_DICT = dict()
1551
+ params['files'] = [i for i in files]
1552
+ if node_id is not None:
1553
+ params['nodeId'] = node_id.to_json()
1554
+ if backend_node_id is not None:
1555
+ params['backendNodeId'] = backend_node_id.to_json()
1556
+ if object_id is not None:
1557
+ params['objectId'] = object_id.to_json()
1558
+ cmd_dict: T_JSON_DICT = {
1559
+ 'method': 'DOM.setFileInputFiles',
1560
+ 'params': params,
1561
+ }
1562
+ json = yield cmd_dict
1563
+
1564
+
1565
+ def set_node_stack_traces_enabled(
1566
+ enable: bool
1567
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1568
+ '''
1569
+ Sets if stack traces should be captured for Nodes. See ``Node.getNodeStackTraces``. Default is disabled.
1570
+
1571
+ **EXPERIMENTAL**
1572
+
1573
+ :param enable: Enable or disable.
1574
+ '''
1575
+ params: T_JSON_DICT = dict()
1576
+ params['enable'] = enable
1577
+ cmd_dict: T_JSON_DICT = {
1578
+ 'method': 'DOM.setNodeStackTracesEnabled',
1579
+ 'params': params,
1580
+ }
1581
+ json = yield cmd_dict
1582
+
1583
+
1584
+ def get_node_stack_traces(
1585
+ node_id: NodeId
1586
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Optional[runtime.StackTrace]]:
1587
+ '''
1588
+ Gets stack traces associated with a Node. As of now, only provides stack trace for Node creation.
1589
+
1590
+ **EXPERIMENTAL**
1591
+
1592
+ :param node_id: Id of the node to get stack traces for.
1593
+ :returns: *(Optional)* Creation stack trace, if available.
1594
+ '''
1595
+ params: T_JSON_DICT = dict()
1596
+ params['nodeId'] = node_id.to_json()
1597
+ cmd_dict: T_JSON_DICT = {
1598
+ 'method': 'DOM.getNodeStackTraces',
1599
+ 'params': params,
1600
+ }
1601
+ json = yield cmd_dict
1602
+ return runtime.StackTrace.from_json(json['creation']) if json.get('creation', None) is not None else None
1603
+
1604
+
1605
+ def get_file_info(
1606
+ object_id: runtime.RemoteObjectId
1607
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
1608
+ '''
1609
+ Returns file information for the given
1610
+ File wrapper.
1611
+
1612
+ **EXPERIMENTAL**
1613
+
1614
+ :param object_id: JavaScript object id of the node wrapper.
1615
+ :returns:
1616
+ '''
1617
+ params: T_JSON_DICT = dict()
1618
+ params['objectId'] = object_id.to_json()
1619
+ cmd_dict: T_JSON_DICT = {
1620
+ 'method': 'DOM.getFileInfo',
1621
+ 'params': params,
1622
+ }
1623
+ json = yield cmd_dict
1624
+ return str(json['path'])
1625
+
1626
+
1627
+ def get_detached_dom_nodes() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[DetachedElementInfo]]:
1628
+ '''
1629
+ Returns list of detached nodes
1630
+
1631
+ **EXPERIMENTAL**
1632
+
1633
+ :returns: The list of detached nodes
1634
+ '''
1635
+ cmd_dict: T_JSON_DICT = {
1636
+ 'method': 'DOM.getDetachedDomNodes',
1637
+ }
1638
+ json = yield cmd_dict
1639
+ return [DetachedElementInfo.from_json(i) for i in json['detachedNodes']]
1640
+
1641
+
1642
+ def set_inspected_node(
1643
+ node_id: NodeId
1644
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1645
+ '''
1646
+ Enables console to refer to the node with given id via $x (see Command Line API for more details
1647
+ $x functions).
1648
+
1649
+ **EXPERIMENTAL**
1650
+
1651
+ :param node_id: DOM node id to be accessible by means of $x command line API.
1652
+ '''
1653
+ params: T_JSON_DICT = dict()
1654
+ params['nodeId'] = node_id.to_json()
1655
+ cmd_dict: T_JSON_DICT = {
1656
+ 'method': 'DOM.setInspectedNode',
1657
+ 'params': params,
1658
+ }
1659
+ json = yield cmd_dict
1660
+
1661
+
1662
+ def set_node_name(
1663
+ node_id: NodeId,
1664
+ name: str
1665
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,NodeId]:
1666
+ '''
1667
+ Sets node name for a node with given id.
1668
+
1669
+ :param node_id: Id of the node to set name for.
1670
+ :param name: New node's name.
1671
+ :returns: New node's id.
1672
+ '''
1673
+ params: T_JSON_DICT = dict()
1674
+ params['nodeId'] = node_id.to_json()
1675
+ params['name'] = name
1676
+ cmd_dict: T_JSON_DICT = {
1677
+ 'method': 'DOM.setNodeName',
1678
+ 'params': params,
1679
+ }
1680
+ json = yield cmd_dict
1681
+ return NodeId.from_json(json['nodeId'])
1682
+
1683
+
1684
+ def set_node_value(
1685
+ node_id: NodeId,
1686
+ value: str
1687
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1688
+ '''
1689
+ Sets node value for a node with given id.
1690
+
1691
+ :param node_id: Id of the node to set value for.
1692
+ :param value: New node's value.
1693
+ '''
1694
+ params: T_JSON_DICT = dict()
1695
+ params['nodeId'] = node_id.to_json()
1696
+ params['value'] = value
1697
+ cmd_dict: T_JSON_DICT = {
1698
+ 'method': 'DOM.setNodeValue',
1699
+ 'params': params,
1700
+ }
1701
+ json = yield cmd_dict
1702
+
1703
+
1704
+ def set_outer_html(
1705
+ node_id: NodeId,
1706
+ outer_html: str
1707
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1708
+ '''
1709
+ Sets node HTML markup, returns new node id.
1710
+
1711
+ :param node_id: Id of the node to set markup for.
1712
+ :param outer_html: Outer HTML markup to set.
1713
+ '''
1714
+ params: T_JSON_DICT = dict()
1715
+ params['nodeId'] = node_id.to_json()
1716
+ params['outerHTML'] = outer_html
1717
+ cmd_dict: T_JSON_DICT = {
1718
+ 'method': 'DOM.setOuterHTML',
1719
+ 'params': params,
1720
+ }
1721
+ json = yield cmd_dict
1722
+
1723
+
1724
+ def undo() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
1725
+ '''
1726
+ Undoes the last performed action.
1727
+
1728
+ **EXPERIMENTAL**
1729
+ '''
1730
+ cmd_dict: T_JSON_DICT = {
1731
+ 'method': 'DOM.undo',
1732
+ }
1733
+ json = yield cmd_dict
1734
+
1735
+
1736
+ def get_frame_owner(
1737
+ frame_id: page.FrameId
1738
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[BackendNodeId, typing.Optional[NodeId]]]:
1739
+ '''
1740
+ Returns iframe node that owns iframe with the given domain.
1741
+
1742
+ **EXPERIMENTAL**
1743
+
1744
+ :param frame_id:
1745
+ :returns: A tuple with the following items:
1746
+
1747
+ 0. **backendNodeId** - Resulting node.
1748
+ 1. **nodeId** - *(Optional)* Id of the node at given coordinates, only when enabled and requested document.
1749
+ '''
1750
+ params: T_JSON_DICT = dict()
1751
+ params['frameId'] = frame_id.to_json()
1752
+ cmd_dict: T_JSON_DICT = {
1753
+ 'method': 'DOM.getFrameOwner',
1754
+ 'params': params,
1755
+ }
1756
+ json = yield cmd_dict
1757
+ return (
1758
+ BackendNodeId.from_json(json['backendNodeId']),
1759
+ NodeId.from_json(json['nodeId']) if json.get('nodeId', None) is not None else None
1760
+ )
1761
+
1762
+
1763
+ def get_container_for_node(
1764
+ node_id: NodeId,
1765
+ container_name: typing.Optional[str] = None,
1766
+ physical_axes: typing.Optional[PhysicalAxes] = None,
1767
+ logical_axes: typing.Optional[LogicalAxes] = None,
1768
+ queries_scroll_state: typing.Optional[bool] = None,
1769
+ queries_anchored: typing.Optional[bool] = None
1770
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Optional[NodeId]]:
1771
+ '''
1772
+ Returns the query container of the given node based on container query
1773
+ conditions: containerName, physical and logical axes, and whether it queries
1774
+ scroll-state or anchored elements. If no axes are provided and
1775
+ queriesScrollState is false, the style container is returned, which is the
1776
+ direct parent or the closest element with a matching container-name.
1777
+
1778
+ **EXPERIMENTAL**
1779
+
1780
+ :param node_id:
1781
+ :param container_name: *(Optional)*
1782
+ :param physical_axes: *(Optional)*
1783
+ :param logical_axes: *(Optional)*
1784
+ :param queries_scroll_state: *(Optional)*
1785
+ :param queries_anchored: *(Optional)*
1786
+ :returns: *(Optional)* The container node for the given node, or null if not found.
1787
+ '''
1788
+ params: T_JSON_DICT = dict()
1789
+ params['nodeId'] = node_id.to_json()
1790
+ if container_name is not None:
1791
+ params['containerName'] = container_name
1792
+ if physical_axes is not None:
1793
+ params['physicalAxes'] = physical_axes.to_json()
1794
+ if logical_axes is not None:
1795
+ params['logicalAxes'] = logical_axes.to_json()
1796
+ if queries_scroll_state is not None:
1797
+ params['queriesScrollState'] = queries_scroll_state
1798
+ if queries_anchored is not None:
1799
+ params['queriesAnchored'] = queries_anchored
1800
+ cmd_dict: T_JSON_DICT = {
1801
+ 'method': 'DOM.getContainerForNode',
1802
+ 'params': params,
1803
+ }
1804
+ json = yield cmd_dict
1805
+ return NodeId.from_json(json['nodeId']) if json.get('nodeId', None) is not None else None
1806
+
1807
+
1808
+ def get_querying_descendants_for_container(
1809
+ node_id: NodeId
1810
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[NodeId]]:
1811
+ '''
1812
+ Returns the descendants of a container query container that have
1813
+ container queries against this container.
1814
+
1815
+ **EXPERIMENTAL**
1816
+
1817
+ :param node_id: Id of the container node to find querying descendants from.
1818
+ :returns: Descendant nodes with container queries against the given container.
1819
+ '''
1820
+ params: T_JSON_DICT = dict()
1821
+ params['nodeId'] = node_id.to_json()
1822
+ cmd_dict: T_JSON_DICT = {
1823
+ 'method': 'DOM.getQueryingDescendantsForContainer',
1824
+ 'params': params,
1825
+ }
1826
+ json = yield cmd_dict
1827
+ return [NodeId.from_json(i) for i in json['nodeIds']]
1828
+
1829
+
1830
+ def get_anchor_element(
1831
+ node_id: NodeId,
1832
+ anchor_specifier: typing.Optional[str] = None
1833
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,NodeId]:
1834
+ '''
1835
+ Returns the target anchor element of the given anchor query according to
1836
+ https://www.w3.org/TR/css-anchor-position-1/#target.
1837
+
1838
+ **EXPERIMENTAL**
1839
+
1840
+ :param node_id: Id of the positioned element from which to find the anchor.
1841
+ :param anchor_specifier: *(Optional)* An optional anchor specifier, as defined in https://www.w3.org/TR/css-anchor-position-1/#anchor-specifier. If not provided, it will return the implicit anchor element for the given positioned element.
1842
+ :returns: The anchor element of the given anchor query.
1843
+ '''
1844
+ params: T_JSON_DICT = dict()
1845
+ params['nodeId'] = node_id.to_json()
1846
+ if anchor_specifier is not None:
1847
+ params['anchorSpecifier'] = anchor_specifier
1848
+ cmd_dict: T_JSON_DICT = {
1849
+ 'method': 'DOM.getAnchorElement',
1850
+ 'params': params,
1851
+ }
1852
+ json = yield cmd_dict
1853
+ return NodeId.from_json(json['nodeId'])
1854
+
1855
+
1856
+ def force_show_popover(
1857
+ node_id: NodeId,
1858
+ enable: bool
1859
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[NodeId]]:
1860
+ '''
1861
+ When enabling, this API force-opens the popover identified by nodeId
1862
+ and keeps it open until disabled.
1863
+
1864
+ **EXPERIMENTAL**
1865
+
1866
+ :param node_id: Id of the popover HTMLElement
1867
+ :param enable: If true, opens the popover and keeps it open. If false, closes the popover if it was previously force-opened.
1868
+ :returns: List of popovers that were closed in order to respect popover stacking order.
1869
+ '''
1870
+ params: T_JSON_DICT = dict()
1871
+ params['nodeId'] = node_id.to_json()
1872
+ params['enable'] = enable
1873
+ cmd_dict: T_JSON_DICT = {
1874
+ 'method': 'DOM.forceShowPopover',
1875
+ 'params': params,
1876
+ }
1877
+ json = yield cmd_dict
1878
+ return [NodeId.from_json(i) for i in json['nodeIds']]
1879
+
1880
+
1881
+ @event_class('DOM.attributeModified')
1882
+ @dataclass
1883
+ class AttributeModified:
1884
+ '''
1885
+ Fired when ``Element``'s attribute is modified.
1886
+ '''
1887
+ #: Id of the node that has changed.
1888
+ node_id: NodeId
1889
+ #: Attribute name.
1890
+ name: str
1891
+ #: Attribute value.
1892
+ value: str
1893
+
1894
+ @classmethod
1895
+ def from_json(cls, json: T_JSON_DICT) -> AttributeModified:
1896
+ return cls(
1897
+ node_id=NodeId.from_json(json['nodeId']),
1898
+ name=str(json['name']),
1899
+ value=str(json['value'])
1900
+ )
1901
+
1902
+
1903
+ @event_class('DOM.adoptedStyleSheetsModified')
1904
+ @dataclass
1905
+ class AdoptedStyleSheetsModified:
1906
+ '''
1907
+ **EXPERIMENTAL**
1908
+
1909
+ Fired when ``Element``'s adoptedStyleSheets are modified.
1910
+ '''
1911
+ #: Id of the node that has changed.
1912
+ node_id: NodeId
1913
+ #: New adoptedStyleSheets array.
1914
+ adopted_style_sheets: typing.List[StyleSheetId]
1915
+
1916
+ @classmethod
1917
+ def from_json(cls, json: T_JSON_DICT) -> AdoptedStyleSheetsModified:
1918
+ return cls(
1919
+ node_id=NodeId.from_json(json['nodeId']),
1920
+ adopted_style_sheets=[StyleSheetId.from_json(i) for i in json['adoptedStyleSheets']]
1921
+ )
1922
+
1923
+
1924
+ @event_class('DOM.attributeRemoved')
1925
+ @dataclass
1926
+ class AttributeRemoved:
1927
+ '''
1928
+ Fired when ``Element``'s attribute is removed.
1929
+ '''
1930
+ #: Id of the node that has changed.
1931
+ node_id: NodeId
1932
+ #: A ttribute name.
1933
+ name: str
1934
+
1935
+ @classmethod
1936
+ def from_json(cls, json: T_JSON_DICT) -> AttributeRemoved:
1937
+ return cls(
1938
+ node_id=NodeId.from_json(json['nodeId']),
1939
+ name=str(json['name'])
1940
+ )
1941
+
1942
+
1943
+ @event_class('DOM.characterDataModified')
1944
+ @dataclass
1945
+ class CharacterDataModified:
1946
+ '''
1947
+ Mirrors ``DOMCharacterDataModified`` event.
1948
+ '''
1949
+ #: Id of the node that has changed.
1950
+ node_id: NodeId
1951
+ #: New text value.
1952
+ character_data: str
1953
+
1954
+ @classmethod
1955
+ def from_json(cls, json: T_JSON_DICT) -> CharacterDataModified:
1956
+ return cls(
1957
+ node_id=NodeId.from_json(json['nodeId']),
1958
+ character_data=str(json['characterData'])
1959
+ )
1960
+
1961
+
1962
+ @event_class('DOM.childNodeCountUpdated')
1963
+ @dataclass
1964
+ class ChildNodeCountUpdated:
1965
+ '''
1966
+ Fired when ``Container``'s child node count has changed.
1967
+ '''
1968
+ #: Id of the node that has changed.
1969
+ node_id: NodeId
1970
+ #: New node count.
1971
+ child_node_count: int
1972
+
1973
+ @classmethod
1974
+ def from_json(cls, json: T_JSON_DICT) -> ChildNodeCountUpdated:
1975
+ return cls(
1976
+ node_id=NodeId.from_json(json['nodeId']),
1977
+ child_node_count=int(json['childNodeCount'])
1978
+ )
1979
+
1980
+
1981
+ @event_class('DOM.childNodeInserted')
1982
+ @dataclass
1983
+ class ChildNodeInserted:
1984
+ '''
1985
+ Mirrors ``DOMNodeInserted`` event.
1986
+ '''
1987
+ #: Id of the node that has changed.
1988
+ parent_node_id: NodeId
1989
+ #: Id of the previous sibling.
1990
+ previous_node_id: NodeId
1991
+ #: Inserted node data.
1992
+ node: Node
1993
+
1994
+ @classmethod
1995
+ def from_json(cls, json: T_JSON_DICT) -> ChildNodeInserted:
1996
+ return cls(
1997
+ parent_node_id=NodeId.from_json(json['parentNodeId']),
1998
+ previous_node_id=NodeId.from_json(json['previousNodeId']),
1999
+ node=Node.from_json(json['node'])
2000
+ )
2001
+
2002
+
2003
+ @event_class('DOM.childNodeRemoved')
2004
+ @dataclass
2005
+ class ChildNodeRemoved:
2006
+ '''
2007
+ Mirrors ``DOMNodeRemoved`` event.
2008
+ '''
2009
+ #: Parent id.
2010
+ parent_node_id: NodeId
2011
+ #: Id of the node that has been removed.
2012
+ node_id: NodeId
2013
+
2014
+ @classmethod
2015
+ def from_json(cls, json: T_JSON_DICT) -> ChildNodeRemoved:
2016
+ return cls(
2017
+ parent_node_id=NodeId.from_json(json['parentNodeId']),
2018
+ node_id=NodeId.from_json(json['nodeId'])
2019
+ )
2020
+
2021
+
2022
+ @event_class('DOM.distributedNodesUpdated')
2023
+ @dataclass
2024
+ class DistributedNodesUpdated:
2025
+ '''
2026
+ **EXPERIMENTAL**
2027
+
2028
+ Called when distribution is changed.
2029
+ '''
2030
+ #: Insertion point where distributed nodes were updated.
2031
+ insertion_point_id: NodeId
2032
+ #: Distributed nodes for given insertion point.
2033
+ distributed_nodes: typing.List[BackendNode]
2034
+
2035
+ @classmethod
2036
+ def from_json(cls, json: T_JSON_DICT) -> DistributedNodesUpdated:
2037
+ return cls(
2038
+ insertion_point_id=NodeId.from_json(json['insertionPointId']),
2039
+ distributed_nodes=[BackendNode.from_json(i) for i in json['distributedNodes']]
2040
+ )
2041
+
2042
+
2043
+ @event_class('DOM.documentUpdated')
2044
+ @dataclass
2045
+ class DocumentUpdated:
2046
+ '''
2047
+ Fired when ``Document`` has been totally updated. Node ids are no longer valid.
2048
+ '''
2049
+
2050
+
2051
+ @classmethod
2052
+ def from_json(cls, json: T_JSON_DICT) -> DocumentUpdated:
2053
+ return cls(
2054
+
2055
+ )
2056
+
2057
+
2058
+ @event_class('DOM.inlineStyleInvalidated')
2059
+ @dataclass
2060
+ class InlineStyleInvalidated:
2061
+ '''
2062
+ **EXPERIMENTAL**
2063
+
2064
+ Fired when ``Element``'s inline style is modified via a CSS property modification.
2065
+ '''
2066
+ #: Ids of the nodes for which the inline styles have been invalidated.
2067
+ node_ids: typing.List[NodeId]
2068
+
2069
+ @classmethod
2070
+ def from_json(cls, json: T_JSON_DICT) -> InlineStyleInvalidated:
2071
+ return cls(
2072
+ node_ids=[NodeId.from_json(i) for i in json['nodeIds']]
2073
+ )
2074
+
2075
+
2076
+ @event_class('DOM.pseudoElementAdded')
2077
+ @dataclass
2078
+ class PseudoElementAdded:
2079
+ '''
2080
+ **EXPERIMENTAL**
2081
+
2082
+ Called when a pseudo element is added to an element.
2083
+ '''
2084
+ #: Pseudo element's parent element id.
2085
+ parent_id: NodeId
2086
+ #: The added pseudo element.
2087
+ pseudo_element: Node
2088
+
2089
+ @classmethod
2090
+ def from_json(cls, json: T_JSON_DICT) -> PseudoElementAdded:
2091
+ return cls(
2092
+ parent_id=NodeId.from_json(json['parentId']),
2093
+ pseudo_element=Node.from_json(json['pseudoElement'])
2094
+ )
2095
+
2096
+
2097
+ @event_class('DOM.topLayerElementsUpdated')
2098
+ @dataclass
2099
+ class TopLayerElementsUpdated:
2100
+ '''
2101
+ **EXPERIMENTAL**
2102
+
2103
+ Called when top layer elements are changed.
2104
+ '''
2105
+
2106
+
2107
+ @classmethod
2108
+ def from_json(cls, json: T_JSON_DICT) -> TopLayerElementsUpdated:
2109
+ return cls(
2110
+
2111
+ )
2112
+
2113
+
2114
+ @event_class('DOM.scrollableFlagUpdated')
2115
+ @dataclass
2116
+ class ScrollableFlagUpdated:
2117
+ '''
2118
+ **EXPERIMENTAL**
2119
+
2120
+ Fired when a node's scrollability state changes.
2121
+ '''
2122
+ #: The id of the node.
2123
+ node_id: NodeId
2124
+ #: If the node is scrollable.
2125
+ is_scrollable: bool
2126
+
2127
+ @classmethod
2128
+ def from_json(cls, json: T_JSON_DICT) -> ScrollableFlagUpdated:
2129
+ return cls(
2130
+ node_id=NodeId.from_json(json['nodeId']),
2131
+ is_scrollable=bool(json['isScrollable'])
2132
+ )
2133
+
2134
+
2135
+ @event_class('DOM.adRelatedStateUpdated')
2136
+ @dataclass
2137
+ class AdRelatedStateUpdated:
2138
+ '''
2139
+ **EXPERIMENTAL**
2140
+
2141
+ Fired when a node's ad related state changes.
2142
+ '''
2143
+ #: The id of the node.
2144
+ node_id: NodeId
2145
+ #: The provenance of the ad related node, if it is ad related.
2146
+ ad_provenance: typing.Optional[network.AdProvenance]
2147
+
2148
+ @classmethod
2149
+ def from_json(cls, json: T_JSON_DICT) -> AdRelatedStateUpdated:
2150
+ return cls(
2151
+ node_id=NodeId.from_json(json['nodeId']),
2152
+ ad_provenance=network.AdProvenance.from_json(json['adProvenance']) if json.get('adProvenance', None) is not None else None
2153
+ )
2154
+
2155
+
2156
+ @event_class('DOM.affectedByStartingStylesFlagUpdated')
2157
+ @dataclass
2158
+ class AffectedByStartingStylesFlagUpdated:
2159
+ '''
2160
+ **EXPERIMENTAL**
2161
+
2162
+ Fired when a node's starting styles changes.
2163
+ '''
2164
+ #: The id of the node.
2165
+ node_id: NodeId
2166
+ #: If the node has starting styles.
2167
+ affected_by_starting_styles: bool
2168
+
2169
+ @classmethod
2170
+ def from_json(cls, json: T_JSON_DICT) -> AffectedByStartingStylesFlagUpdated:
2171
+ return cls(
2172
+ node_id=NodeId.from_json(json['nodeId']),
2173
+ affected_by_starting_styles=bool(json['affectedByStartingStyles'])
2174
+ )
2175
+
2176
+
2177
+ @event_class('DOM.pseudoElementRemoved')
2178
+ @dataclass
2179
+ class PseudoElementRemoved:
2180
+ '''
2181
+ **EXPERIMENTAL**
2182
+
2183
+ Called when a pseudo element is removed from an element.
2184
+ '''
2185
+ #: Pseudo element's parent element id.
2186
+ parent_id: NodeId
2187
+ #: The removed pseudo element id.
2188
+ pseudo_element_id: NodeId
2189
+
2190
+ @classmethod
2191
+ def from_json(cls, json: T_JSON_DICT) -> PseudoElementRemoved:
2192
+ return cls(
2193
+ parent_id=NodeId.from_json(json['parentId']),
2194
+ pseudo_element_id=NodeId.from_json(json['pseudoElementId'])
2195
+ )
2196
+
2197
+
2198
+ @event_class('DOM.setChildNodes')
2199
+ @dataclass
2200
+ class SetChildNodes:
2201
+ '''
2202
+ Fired when backend wants to provide client with the missing DOM structure. This happens upon
2203
+ most of the calls requesting node ids.
2204
+ '''
2205
+ #: Parent node id to populate with children.
2206
+ parent_id: NodeId
2207
+ #: Child nodes array.
2208
+ nodes: typing.List[Node]
2209
+
2210
+ @classmethod
2211
+ def from_json(cls, json: T_JSON_DICT) -> SetChildNodes:
2212
+ return cls(
2213
+ parent_id=NodeId.from_json(json['parentId']),
2214
+ nodes=[Node.from_json(i) for i in json['nodes']]
2215
+ )
2216
+
2217
+
2218
+ @event_class('DOM.shadowRootPopped')
2219
+ @dataclass
2220
+ class ShadowRootPopped:
2221
+ '''
2222
+ **EXPERIMENTAL**
2223
+
2224
+ Called when shadow root is popped from the element.
2225
+ '''
2226
+ #: Host element id.
2227
+ host_id: NodeId
2228
+ #: Shadow root id.
2229
+ root_id: NodeId
2230
+
2231
+ @classmethod
2232
+ def from_json(cls, json: T_JSON_DICT) -> ShadowRootPopped:
2233
+ return cls(
2234
+ host_id=NodeId.from_json(json['hostId']),
2235
+ root_id=NodeId.from_json(json['rootId'])
2236
+ )
2237
+
2238
+
2239
+ @event_class('DOM.shadowRootPushed')
2240
+ @dataclass
2241
+ class ShadowRootPushed:
2242
+ '''
2243
+ **EXPERIMENTAL**
2244
+
2245
+ Called when shadow root is pushed into the element.
2246
+ '''
2247
+ #: Host element id.
2248
+ host_id: NodeId
2249
+ #: Shadow root.
2250
+ root: Node
2251
+
2252
+ @classmethod
2253
+ def from_json(cls, json: T_JSON_DICT) -> ShadowRootPushed:
2254
+ return cls(
2255
+ host_id=NodeId.from_json(json['hostId']),
2256
+ root=Node.from_json(json['root'])
2257
+ )