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/input_.py ADDED
@@ -0,0 +1,701 @@
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: Input
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
+
15
+ @dataclass
16
+ class TouchPoint:
17
+ #: X coordinate of the event relative to the main frame's viewport in CSS pixels.
18
+ x: float
19
+
20
+ #: Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to
21
+ #: the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
22
+ y: float
23
+
24
+ #: X radius of the touch area (default: 1.0).
25
+ radius_x: typing.Optional[float] = None
26
+
27
+ #: Y radius of the touch area (default: 1.0).
28
+ radius_y: typing.Optional[float] = None
29
+
30
+ #: Rotation angle (default: 0.0).
31
+ rotation_angle: typing.Optional[float] = None
32
+
33
+ #: Force (default: 1.0).
34
+ force: typing.Optional[float] = None
35
+
36
+ #: The normalized tangential pressure, which has a range of [-1,1] (default: 0).
37
+ tangential_pressure: typing.Optional[float] = None
38
+
39
+ #: The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0)
40
+ tilt_x: typing.Optional[float] = None
41
+
42
+ #: The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0).
43
+ tilt_y: typing.Optional[float] = None
44
+
45
+ #: The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0).
46
+ twist: typing.Optional[int] = None
47
+
48
+ #: Identifier used to track touch sources between events, must be unique within an event.
49
+ id_: typing.Optional[float] = None
50
+
51
+ def to_json(self) -> T_JSON_DICT:
52
+ json: T_JSON_DICT = dict()
53
+ json['x'] = self.x
54
+ json['y'] = self.y
55
+ if self.radius_x is not None:
56
+ json['radiusX'] = self.radius_x
57
+ if self.radius_y is not None:
58
+ json['radiusY'] = self.radius_y
59
+ if self.rotation_angle is not None:
60
+ json['rotationAngle'] = self.rotation_angle
61
+ if self.force is not None:
62
+ json['force'] = self.force
63
+ if self.tangential_pressure is not None:
64
+ json['tangentialPressure'] = self.tangential_pressure
65
+ if self.tilt_x is not None:
66
+ json['tiltX'] = self.tilt_x
67
+ if self.tilt_y is not None:
68
+ json['tiltY'] = self.tilt_y
69
+ if self.twist is not None:
70
+ json['twist'] = self.twist
71
+ if self.id_ is not None:
72
+ json['id'] = self.id_
73
+ return json
74
+
75
+ @classmethod
76
+ def from_json(cls, json: T_JSON_DICT) -> TouchPoint:
77
+ return cls(
78
+ x=float(json['x']),
79
+ y=float(json['y']),
80
+ radius_x=float(json['radiusX']) if json.get('radiusX', None) is not None else None,
81
+ radius_y=float(json['radiusY']) if json.get('radiusY', None) is not None else None,
82
+ rotation_angle=float(json['rotationAngle']) if json.get('rotationAngle', None) is not None else None,
83
+ force=float(json['force']) if json.get('force', None) is not None else None,
84
+ tangential_pressure=float(json['tangentialPressure']) if json.get('tangentialPressure', None) is not None else None,
85
+ tilt_x=float(json['tiltX']) if json.get('tiltX', None) is not None else None,
86
+ tilt_y=float(json['tiltY']) if json.get('tiltY', None) is not None else None,
87
+ twist=int(json['twist']) if json.get('twist', None) is not None else None,
88
+ id_=float(json['id']) if json.get('id', None) is not None else None,
89
+ )
90
+
91
+
92
+ class GestureSourceType(enum.Enum):
93
+ DEFAULT = "default"
94
+ TOUCH = "touch"
95
+ MOUSE = "mouse"
96
+
97
+ def to_json(self) -> str:
98
+ return self.value
99
+
100
+ @classmethod
101
+ def from_json(cls, json: str) -> GestureSourceType:
102
+ return cls(json)
103
+
104
+
105
+ class MouseButton(enum.Enum):
106
+ NONE = "none"
107
+ LEFT = "left"
108
+ MIDDLE = "middle"
109
+ RIGHT = "right"
110
+ BACK = "back"
111
+ FORWARD = "forward"
112
+
113
+ def to_json(self) -> str:
114
+ return self.value
115
+
116
+ @classmethod
117
+ def from_json(cls, json: str) -> MouseButton:
118
+ return cls(json)
119
+
120
+
121
+ class TimeSinceEpoch(float):
122
+ '''
123
+ UTC time in seconds, counted from January 1, 1970.
124
+ '''
125
+ def to_json(self) -> float:
126
+ return self
127
+
128
+ @classmethod
129
+ def from_json(cls, json: float) -> TimeSinceEpoch:
130
+ return cls(json)
131
+
132
+ def __repr__(self):
133
+ return 'TimeSinceEpoch({})'.format(super().__repr__())
134
+
135
+
136
+ @dataclass
137
+ class DragDataItem:
138
+ #: Mime type of the dragged data.
139
+ mime_type: str
140
+
141
+ #: Depending of the value of ``mimeType``, it contains the dragged link,
142
+ #: text, HTML markup or any other data.
143
+ data: str
144
+
145
+ #: Title associated with a link. Only valid when ``mimeType`` == "text/uri-list".
146
+ title: typing.Optional[str] = None
147
+
148
+ #: Stores the base URL for the contained markup. Only valid when ``mimeType``
149
+ #: == "text/html".
150
+ base_url: typing.Optional[str] = None
151
+
152
+ def to_json(self) -> T_JSON_DICT:
153
+ json: T_JSON_DICT = dict()
154
+ json['mimeType'] = self.mime_type
155
+ json['data'] = self.data
156
+ if self.title is not None:
157
+ json['title'] = self.title
158
+ if self.base_url is not None:
159
+ json['baseURL'] = self.base_url
160
+ return json
161
+
162
+ @classmethod
163
+ def from_json(cls, json: T_JSON_DICT) -> DragDataItem:
164
+ return cls(
165
+ mime_type=str(json['mimeType']),
166
+ data=str(json['data']),
167
+ title=str(json['title']) if json.get('title', None) is not None else None,
168
+ base_url=str(json['baseURL']) if json.get('baseURL', None) is not None else None,
169
+ )
170
+
171
+
172
+ @dataclass
173
+ class DragData:
174
+ items: typing.List[DragDataItem]
175
+
176
+ #: Bit field representing allowed drag operations. Copy = 1, Link = 2, Move = 16
177
+ drag_operations_mask: int
178
+
179
+ #: List of filenames that should be included when dropping
180
+ files: typing.Optional[typing.List[str]] = None
181
+
182
+ def to_json(self) -> T_JSON_DICT:
183
+ json: T_JSON_DICT = dict()
184
+ json['items'] = [i.to_json() for i in self.items]
185
+ json['dragOperationsMask'] = self.drag_operations_mask
186
+ if self.files is not None:
187
+ json['files'] = [i for i in self.files]
188
+ return json
189
+
190
+ @classmethod
191
+ def from_json(cls, json: T_JSON_DICT) -> DragData:
192
+ return cls(
193
+ items=[DragDataItem.from_json(i) for i in json['items']],
194
+ drag_operations_mask=int(json['dragOperationsMask']),
195
+ files=[str(i) for i in json['files']] if json.get('files', None) is not None else None,
196
+ )
197
+
198
+
199
+ def dispatch_drag_event(
200
+ type_: str,
201
+ x: float,
202
+ y: float,
203
+ data: DragData,
204
+ modifiers: typing.Optional[int] = None
205
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
206
+ '''
207
+ Dispatches a drag event into the page.
208
+
209
+ **EXPERIMENTAL**
210
+
211
+ :param type_: Type of the drag event.
212
+ :param x: X coordinate of the event relative to the main frame's viewport in CSS pixels.
213
+ :param y: Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
214
+ :param data:
215
+ :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
216
+ '''
217
+ params: T_JSON_DICT = dict()
218
+ params['type'] = type_
219
+ params['x'] = x
220
+ params['y'] = y
221
+ params['data'] = data.to_json()
222
+ if modifiers is not None:
223
+ params['modifiers'] = modifiers
224
+ cmd_dict: T_JSON_DICT = {
225
+ 'method': 'Input.dispatchDragEvent',
226
+ 'params': params,
227
+ }
228
+ json = yield cmd_dict
229
+
230
+
231
+ def dispatch_key_event(
232
+ type_: str,
233
+ modifiers: typing.Optional[int] = None,
234
+ timestamp: typing.Optional[TimeSinceEpoch] = None,
235
+ text: typing.Optional[str] = None,
236
+ unmodified_text: typing.Optional[str] = None,
237
+ key_identifier: typing.Optional[str] = None,
238
+ code: typing.Optional[str] = None,
239
+ key: typing.Optional[str] = None,
240
+ windows_virtual_key_code: typing.Optional[int] = None,
241
+ native_virtual_key_code: typing.Optional[int] = None,
242
+ auto_repeat: typing.Optional[bool] = None,
243
+ is_keypad: typing.Optional[bool] = None,
244
+ is_system_key: typing.Optional[bool] = None,
245
+ location: typing.Optional[int] = None,
246
+ commands: typing.Optional[typing.List[str]] = None
247
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
248
+ '''
249
+ Dispatches a key event to the page.
250
+
251
+ :param type_: Type of the key event.
252
+ :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
253
+ :param timestamp: *(Optional)* Time at which the event occurred.
254
+ :param text: *(Optional)* Text as generated by processing a virtual key code with a keyboard layout. Not needed for for ```keyUp```` and ````rawKeyDown```` events (default: "")
255
+ :param unmodified_text: *(Optional)* Text that would have been generated by the keyboard if no modifiers were pressed (except for shift). Useful for shortcut (accelerator) key handling (default: "").
256
+ :param key_identifier: *(Optional)* Unique key identifier (e.g., 'U+0041') (default: "").
257
+ :param code: *(Optional)* Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: "").
258
+ :param key: *(Optional)* Unique DOM defined string value describing the meaning of the key in the context of active modifiers, keyboard layout, etc (e.g., 'AltGr') (default: "").
259
+ :param windows_virtual_key_code: *(Optional)* Windows virtual key code (default: 0).
260
+ :param native_virtual_key_code: *(Optional)* Native virtual key code (default: 0).
261
+ :param auto_repeat: *(Optional)* Whether the event was generated from auto repeat (default: false).
262
+ :param is_keypad: *(Optional)* Whether the event was generated from the keypad (default: false).
263
+ :param is_system_key: *(Optional)* Whether the event was a system key event (default: false).
264
+ :param location: *(Optional)* Whether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default: 0).
265
+ :param commands: **(EXPERIMENTAL)** *(Optional)* Editing commands to send with the key event (e.g., 'selectAll') (default: []). These are related to but not equal the command names used in ````document.execCommand``` and NSStandardKeyBindingResponding. See https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h for valid command names.
266
+ '''
267
+ params: T_JSON_DICT = dict()
268
+ params['type'] = type_
269
+ if modifiers is not None:
270
+ params['modifiers'] = modifiers
271
+ if timestamp is not None:
272
+ params['timestamp'] = timestamp.to_json()
273
+ if text is not None:
274
+ params['text'] = text
275
+ if unmodified_text is not None:
276
+ params['unmodifiedText'] = unmodified_text
277
+ if key_identifier is not None:
278
+ params['keyIdentifier'] = key_identifier
279
+ if code is not None:
280
+ params['code'] = code
281
+ if key is not None:
282
+ params['key'] = key
283
+ if windows_virtual_key_code is not None:
284
+ params['windowsVirtualKeyCode'] = windows_virtual_key_code
285
+ if native_virtual_key_code is not None:
286
+ params['nativeVirtualKeyCode'] = native_virtual_key_code
287
+ if auto_repeat is not None:
288
+ params['autoRepeat'] = auto_repeat
289
+ if is_keypad is not None:
290
+ params['isKeypad'] = is_keypad
291
+ if is_system_key is not None:
292
+ params['isSystemKey'] = is_system_key
293
+ if location is not None:
294
+ params['location'] = location
295
+ if commands is not None:
296
+ params['commands'] = [i for i in commands]
297
+ cmd_dict: T_JSON_DICT = {
298
+ 'method': 'Input.dispatchKeyEvent',
299
+ 'params': params,
300
+ }
301
+ json = yield cmd_dict
302
+
303
+
304
+ def insert_text(
305
+ text: str
306
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
307
+ '''
308
+ This method emulates inserting text that doesn't come from a key press,
309
+ for example an emoji keyboard or an IME.
310
+
311
+ **EXPERIMENTAL**
312
+
313
+ :param text: The text to insert.
314
+ '''
315
+ params: T_JSON_DICT = dict()
316
+ params['text'] = text
317
+ cmd_dict: T_JSON_DICT = {
318
+ 'method': 'Input.insertText',
319
+ 'params': params,
320
+ }
321
+ json = yield cmd_dict
322
+
323
+
324
+ def ime_set_composition(
325
+ text: str,
326
+ selection_start: int,
327
+ selection_end: int,
328
+ replacement_start: typing.Optional[int] = None,
329
+ replacement_end: typing.Optional[int] = None
330
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
331
+ '''
332
+ This method sets the current candidate text for IME.
333
+ Use imeCommitComposition to commit the final text.
334
+ Use imeSetComposition with empty string as text to cancel composition.
335
+
336
+ **EXPERIMENTAL**
337
+
338
+ :param text: The text to insert
339
+ :param selection_start: selection start
340
+ :param selection_end: selection end
341
+ :param replacement_start: *(Optional)* replacement start
342
+ :param replacement_end: *(Optional)* replacement end
343
+ '''
344
+ params: T_JSON_DICT = dict()
345
+ params['text'] = text
346
+ params['selectionStart'] = selection_start
347
+ params['selectionEnd'] = selection_end
348
+ if replacement_start is not None:
349
+ params['replacementStart'] = replacement_start
350
+ if replacement_end is not None:
351
+ params['replacementEnd'] = replacement_end
352
+ cmd_dict: T_JSON_DICT = {
353
+ 'method': 'Input.imeSetComposition',
354
+ 'params': params,
355
+ }
356
+ json = yield cmd_dict
357
+
358
+
359
+ def dispatch_mouse_event(
360
+ type_: str,
361
+ x: float,
362
+ y: float,
363
+ modifiers: typing.Optional[int] = None,
364
+ timestamp: typing.Optional[TimeSinceEpoch] = None,
365
+ button: typing.Optional[MouseButton] = None,
366
+ buttons: typing.Optional[int] = None,
367
+ click_count: typing.Optional[int] = None,
368
+ force: typing.Optional[float] = None,
369
+ tangential_pressure: typing.Optional[float] = None,
370
+ tilt_x: typing.Optional[float] = None,
371
+ tilt_y: typing.Optional[float] = None,
372
+ twist: typing.Optional[int] = None,
373
+ delta_x: typing.Optional[float] = None,
374
+ delta_y: typing.Optional[float] = None,
375
+ pointer_type: typing.Optional[str] = None
376
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
377
+ '''
378
+ Dispatches a mouse event to the page.
379
+
380
+ :param type_: Type of the mouse event.
381
+ :param x: X coordinate of the event relative to the main frame's viewport in CSS pixels.
382
+ :param y: Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
383
+ :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
384
+ :param timestamp: *(Optional)* Time at which the event occurred.
385
+ :param button: *(Optional)* Mouse button (default: "none").
386
+ :param buttons: *(Optional)* A number indicating which buttons are pressed on the mouse when a mouse event is triggered. Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0.
387
+ :param click_count: *(Optional)* Number of times the mouse button was clicked (default: 0).
388
+ :param force: **(EXPERIMENTAL)** *(Optional)* The normalized pressure, which has a range of [0,1] (default: 0).
389
+ :param tangential_pressure: **(EXPERIMENTAL)** *(Optional)* The normalized tangential pressure, which has a range of [-1,1] (default: 0).
390
+ :param tilt_x: *(Optional)* The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0).
391
+ :param tilt_y: *(Optional)* The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0).
392
+ :param twist: **(EXPERIMENTAL)** *(Optional)* The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0).
393
+ :param delta_x: *(Optional)* X delta in CSS pixels for mouse wheel event (default: 0).
394
+ :param delta_y: *(Optional)* Y delta in CSS pixels for mouse wheel event (default: 0).
395
+ :param pointer_type: *(Optional)* Pointer type (default: "mouse").
396
+ '''
397
+ params: T_JSON_DICT = dict()
398
+ params['type'] = type_
399
+ params['x'] = x
400
+ params['y'] = y
401
+ if modifiers is not None:
402
+ params['modifiers'] = modifiers
403
+ if timestamp is not None:
404
+ params['timestamp'] = timestamp.to_json()
405
+ if button is not None:
406
+ params['button'] = button.to_json()
407
+ if buttons is not None:
408
+ params['buttons'] = buttons
409
+ if click_count is not None:
410
+ params['clickCount'] = click_count
411
+ if force is not None:
412
+ params['force'] = force
413
+ if tangential_pressure is not None:
414
+ params['tangentialPressure'] = tangential_pressure
415
+ if tilt_x is not None:
416
+ params['tiltX'] = tilt_x
417
+ if tilt_y is not None:
418
+ params['tiltY'] = tilt_y
419
+ if twist is not None:
420
+ params['twist'] = twist
421
+ if delta_x is not None:
422
+ params['deltaX'] = delta_x
423
+ if delta_y is not None:
424
+ params['deltaY'] = delta_y
425
+ if pointer_type is not None:
426
+ params['pointerType'] = pointer_type
427
+ cmd_dict: T_JSON_DICT = {
428
+ 'method': 'Input.dispatchMouseEvent',
429
+ 'params': params,
430
+ }
431
+ json = yield cmd_dict
432
+
433
+
434
+ def dispatch_touch_event(
435
+ type_: str,
436
+ touch_points: typing.List[TouchPoint],
437
+ modifiers: typing.Optional[int] = None,
438
+ timestamp: typing.Optional[TimeSinceEpoch] = None
439
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
440
+ '''
441
+ Dispatches a touch event to the page.
442
+
443
+ :param type_: Type of the touch event. TouchEnd and TouchCancel must not contain any touch points, while TouchStart and TouchMove must contains at least one.
444
+ :param touch_points: Active touch points on the touch device. One event per any changed point (compared to previous touch event in a sequence) is generated, emulating pressing/moving/releasing points one by one.
445
+ :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
446
+ :param timestamp: *(Optional)* Time at which the event occurred.
447
+ '''
448
+ params: T_JSON_DICT = dict()
449
+ params['type'] = type_
450
+ params['touchPoints'] = [i.to_json() for i in touch_points]
451
+ if modifiers is not None:
452
+ params['modifiers'] = modifiers
453
+ if timestamp is not None:
454
+ params['timestamp'] = timestamp.to_json()
455
+ cmd_dict: T_JSON_DICT = {
456
+ 'method': 'Input.dispatchTouchEvent',
457
+ 'params': params,
458
+ }
459
+ json = yield cmd_dict
460
+
461
+
462
+ def cancel_dragging() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
463
+ '''
464
+ Cancels any active dragging in the page.
465
+ '''
466
+ cmd_dict: T_JSON_DICT = {
467
+ 'method': 'Input.cancelDragging',
468
+ }
469
+ json = yield cmd_dict
470
+
471
+
472
+ def emulate_touch_from_mouse_event(
473
+ type_: str,
474
+ x: int,
475
+ y: int,
476
+ button: MouseButton,
477
+ timestamp: typing.Optional[TimeSinceEpoch] = None,
478
+ delta_x: typing.Optional[float] = None,
479
+ delta_y: typing.Optional[float] = None,
480
+ modifiers: typing.Optional[int] = None,
481
+ click_count: typing.Optional[int] = None
482
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
483
+ '''
484
+ Emulates touch event from the mouse event parameters.
485
+
486
+ **EXPERIMENTAL**
487
+
488
+ :param type_: Type of the mouse event.
489
+ :param x: X coordinate of the mouse pointer in DIP.
490
+ :param y: Y coordinate of the mouse pointer in DIP.
491
+ :param button: Mouse button. Only "none", "left", "right" are supported.
492
+ :param timestamp: *(Optional)* Time at which the event occurred (default: current time).
493
+ :param delta_x: *(Optional)* X delta in DIP for mouse wheel event (default: 0).
494
+ :param delta_y: *(Optional)* Y delta in DIP for mouse wheel event (default: 0).
495
+ :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
496
+ :param click_count: *(Optional)* Number of times the mouse button was clicked (default: 0).
497
+ '''
498
+ params: T_JSON_DICT = dict()
499
+ params['type'] = type_
500
+ params['x'] = x
501
+ params['y'] = y
502
+ params['button'] = button.to_json()
503
+ if timestamp is not None:
504
+ params['timestamp'] = timestamp.to_json()
505
+ if delta_x is not None:
506
+ params['deltaX'] = delta_x
507
+ if delta_y is not None:
508
+ params['deltaY'] = delta_y
509
+ if modifiers is not None:
510
+ params['modifiers'] = modifiers
511
+ if click_count is not None:
512
+ params['clickCount'] = click_count
513
+ cmd_dict: T_JSON_DICT = {
514
+ 'method': 'Input.emulateTouchFromMouseEvent',
515
+ 'params': params,
516
+ }
517
+ json = yield cmd_dict
518
+
519
+
520
+ def set_ignore_input_events(
521
+ ignore: bool
522
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
523
+ '''
524
+ Ignores input events (useful while auditing page).
525
+
526
+ :param ignore: Ignores input events processing when set to true.
527
+ '''
528
+ params: T_JSON_DICT = dict()
529
+ params['ignore'] = ignore
530
+ cmd_dict: T_JSON_DICT = {
531
+ 'method': 'Input.setIgnoreInputEvents',
532
+ 'params': params,
533
+ }
534
+ json = yield cmd_dict
535
+
536
+
537
+ def set_intercept_drags(
538
+ enabled: bool
539
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
540
+ '''
541
+ Prevents default drag and drop behavior and instead emits ``Input.dragIntercepted`` events.
542
+ Drag and drop behavior can be directly controlled via ``Input.dispatchDragEvent``.
543
+
544
+ **EXPERIMENTAL**
545
+
546
+ :param enabled:
547
+ '''
548
+ params: T_JSON_DICT = dict()
549
+ params['enabled'] = enabled
550
+ cmd_dict: T_JSON_DICT = {
551
+ 'method': 'Input.setInterceptDrags',
552
+ 'params': params,
553
+ }
554
+ json = yield cmd_dict
555
+
556
+
557
+ def synthesize_pinch_gesture(
558
+ x: float,
559
+ y: float,
560
+ scale_factor: float,
561
+ relative_speed: typing.Optional[int] = None,
562
+ gesture_source_type: typing.Optional[GestureSourceType] = None
563
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
564
+ '''
565
+ Synthesizes a pinch gesture over a time period by issuing appropriate touch events.
566
+
567
+ **EXPERIMENTAL**
568
+
569
+ :param x: X coordinate of the start of the gesture in CSS pixels.
570
+ :param y: Y coordinate of the start of the gesture in CSS pixels.
571
+ :param scale_factor: Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out).
572
+ :param relative_speed: *(Optional)* Relative pointer speed in pixels per second (default: 800).
573
+ :param gesture_source_type: *(Optional)* Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
574
+ '''
575
+ params: T_JSON_DICT = dict()
576
+ params['x'] = x
577
+ params['y'] = y
578
+ params['scaleFactor'] = scale_factor
579
+ if relative_speed is not None:
580
+ params['relativeSpeed'] = relative_speed
581
+ if gesture_source_type is not None:
582
+ params['gestureSourceType'] = gesture_source_type.to_json()
583
+ cmd_dict: T_JSON_DICT = {
584
+ 'method': 'Input.synthesizePinchGesture',
585
+ 'params': params,
586
+ }
587
+ json = yield cmd_dict
588
+
589
+
590
+ def synthesize_scroll_gesture(
591
+ x: float,
592
+ y: float,
593
+ x_distance: typing.Optional[float] = None,
594
+ y_distance: typing.Optional[float] = None,
595
+ x_overscroll: typing.Optional[float] = None,
596
+ y_overscroll: typing.Optional[float] = None,
597
+ prevent_fling: typing.Optional[bool] = None,
598
+ speed: typing.Optional[int] = None,
599
+ gesture_source_type: typing.Optional[GestureSourceType] = None,
600
+ repeat_count: typing.Optional[int] = None,
601
+ repeat_delay_ms: typing.Optional[int] = None,
602
+ interaction_marker_name: typing.Optional[str] = None
603
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
604
+ '''
605
+ Synthesizes a scroll gesture over a time period by issuing appropriate touch events.
606
+
607
+ **EXPERIMENTAL**
608
+
609
+ :param x: X coordinate of the start of the gesture in CSS pixels.
610
+ :param y: Y coordinate of the start of the gesture in CSS pixels.
611
+ :param x_distance: *(Optional)* The distance to scroll along the X axis (positive to scroll left).
612
+ :param y_distance: *(Optional)* The distance to scroll along the Y axis (positive to scroll up).
613
+ :param x_overscroll: *(Optional)* The number of additional pixels to scroll back along the X axis, in addition to the given distance.
614
+ :param y_overscroll: *(Optional)* The number of additional pixels to scroll back along the Y axis, in addition to the given distance.
615
+ :param prevent_fling: *(Optional)* Prevent fling (default: true).
616
+ :param speed: *(Optional)* Swipe speed in pixels per second (default: 800).
617
+ :param gesture_source_type: *(Optional)* Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
618
+ :param repeat_count: *(Optional)* The number of times to repeat the gesture (default: 0).
619
+ :param repeat_delay_ms: *(Optional)* The number of milliseconds delay between each repeat. (default: 250).
620
+ :param interaction_marker_name: *(Optional)* The name of the interaction markers to generate, if not empty (default: "").
621
+ '''
622
+ params: T_JSON_DICT = dict()
623
+ params['x'] = x
624
+ params['y'] = y
625
+ if x_distance is not None:
626
+ params['xDistance'] = x_distance
627
+ if y_distance is not None:
628
+ params['yDistance'] = y_distance
629
+ if x_overscroll is not None:
630
+ params['xOverscroll'] = x_overscroll
631
+ if y_overscroll is not None:
632
+ params['yOverscroll'] = y_overscroll
633
+ if prevent_fling is not None:
634
+ params['preventFling'] = prevent_fling
635
+ if speed is not None:
636
+ params['speed'] = speed
637
+ if gesture_source_type is not None:
638
+ params['gestureSourceType'] = gesture_source_type.to_json()
639
+ if repeat_count is not None:
640
+ params['repeatCount'] = repeat_count
641
+ if repeat_delay_ms is not None:
642
+ params['repeatDelayMs'] = repeat_delay_ms
643
+ if interaction_marker_name is not None:
644
+ params['interactionMarkerName'] = interaction_marker_name
645
+ cmd_dict: T_JSON_DICT = {
646
+ 'method': 'Input.synthesizeScrollGesture',
647
+ 'params': params,
648
+ }
649
+ json = yield cmd_dict
650
+
651
+
652
+ def synthesize_tap_gesture(
653
+ x: float,
654
+ y: float,
655
+ duration: typing.Optional[int] = None,
656
+ tap_count: typing.Optional[int] = None,
657
+ gesture_source_type: typing.Optional[GestureSourceType] = None
658
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
659
+ '''
660
+ Synthesizes a tap gesture over a time period by issuing appropriate touch events.
661
+
662
+ **EXPERIMENTAL**
663
+
664
+ :param x: X coordinate of the start of the gesture in CSS pixels.
665
+ :param y: Y coordinate of the start of the gesture in CSS pixels.
666
+ :param duration: *(Optional)* Duration between touchdown and touchup events in ms (default: 50).
667
+ :param tap_count: *(Optional)* Number of times to perform the tap (e.g. 2 for double tap, default: 1).
668
+ :param gesture_source_type: *(Optional)* Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
669
+ '''
670
+ params: T_JSON_DICT = dict()
671
+ params['x'] = x
672
+ params['y'] = y
673
+ if duration is not None:
674
+ params['duration'] = duration
675
+ if tap_count is not None:
676
+ params['tapCount'] = tap_count
677
+ if gesture_source_type is not None:
678
+ params['gestureSourceType'] = gesture_source_type.to_json()
679
+ cmd_dict: T_JSON_DICT = {
680
+ 'method': 'Input.synthesizeTapGesture',
681
+ 'params': params,
682
+ }
683
+ json = yield cmd_dict
684
+
685
+
686
+ @event_class('Input.dragIntercepted')
687
+ @dataclass
688
+ class DragIntercepted:
689
+ '''
690
+ **EXPERIMENTAL**
691
+
692
+ Emitted only when ``Input.setInterceptDrags`` is enabled. Use this data with ``Input.dispatchDragEvent`` to
693
+ restore normal drag and drop behavior.
694
+ '''
695
+ data: DragData
696
+
697
+ @classmethod
698
+ def from_json(cls, json: T_JSON_DICT) -> DragIntercepted:
699
+ return cls(
700
+ data=DragData.from_json(json['data'])
701
+ )