cdp-driver 0.5.0

Chrome DevTools Protocol (CDP) client for Rust: every command, event and type generated from the schema, with sessions, for browser automation and AI agents
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
// @generated by `just generate-methods` from protocol/*.json.
// Do not edit by hand; edit xtask/ and regenerate.

//! This domain facilitates obtaining document snapshots with DOM, layout, and
//! style information.
//!
//! Types, command parameters and event payloads for the `DOMSnapshot`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].
//!
//! This domain is experimental and may change without notice.

use serde::{Deserialize, Serialize};

/// A Node in the DOM tree.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DomNode {
    /// `Node`'s nodeType.
    #[serde(rename = "nodeType")]
    pub node_type: i64,
    /// `Node`'s nodeName.
    #[serde(rename = "nodeName")]
    pub node_name: String,
    /// `Node`'s nodeValue.
    #[serde(rename = "nodeValue")]
    pub node_value: String,
    /// Only set for textarea elements, contains the text value.
    #[serde(rename = "textValue", default, skip_serializing_if = "Option::is_none")]
    pub text_value: Option<String>,
    /// Only set for input elements, contains the input's associated text value.
    #[serde(
        rename = "inputValue",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub input_value: Option<String>,
    /// Only set for radio and checkbox input elements, indicates if the element
    /// has been checked
    #[serde(
        rename = "inputChecked",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub input_checked: Option<bool>,
    /// Only set for option elements, indicates if the element has been selected
    #[serde(
        rename = "optionSelected",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub option_selected: Option<bool>,
    /// `Node`'s id, corresponds to DOM.Node.backendNodeId.
    #[serde(rename = "backendNodeId")]
    pub backend_node_id: crate::protocol::dom::BackendNodeId,
    /// The indexes of the node's child nodes in the `domNodes` array returned by
    /// `getSnapshot`, if any.
    #[serde(
        rename = "childNodeIndexes",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub child_node_indexes: Option<Vec<i64>>,
    /// Attributes of an `Element` node.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub attributes: Option<Vec<NameValue>>,
    /// Indexes of pseudo elements associated with this node in the `domNodes`
    /// array returned by `getSnapshot`, if any.
    #[serde(
        rename = "pseudoElementIndexes",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub pseudo_element_indexes: Option<Vec<i64>>,
    /// The index of the node's related layout tree node in the `layoutTreeNodes`
    /// array returned by `getSnapshot`, if any.
    #[serde(
        rename = "layoutNodeIndex",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub layout_node_index: Option<i64>,
    /// Document URL that `Document` or `FrameOwner` node points to.
    #[serde(
        rename = "documentURL",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub document_url: Option<String>,
    /// Base URL that `Document` or `FrameOwner` node uses for URL completion.
    #[serde(rename = "baseURL", default, skip_serializing_if = "Option::is_none")]
    pub base_url: Option<String>,
    /// Only set for documents, contains the document's content language.
    #[serde(
        rename = "contentLanguage",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub content_language: Option<String>,
    /// Only set for documents, contains the document's character set encoding.
    #[serde(
        rename = "documentEncoding",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub document_encoding: Option<String>,
    /// `DocumentType` node's publicId.
    #[serde(rename = "publicId", default, skip_serializing_if = "Option::is_none")]
    pub public_id: Option<String>,
    /// `DocumentType` node's systemId.
    #[serde(rename = "systemId", default, skip_serializing_if = "Option::is_none")]
    pub system_id: Option<String>,
    /// Frame ID for frame owner elements and also for the document node.
    #[serde(rename = "frameId", default, skip_serializing_if = "Option::is_none")]
    pub frame_id: Option<crate::protocol::page::FrameId>,
    /// The index of a frame owner element's content document in the `domNodes`
    /// array returned by `getSnapshot`, if any.
    #[serde(
        rename = "contentDocumentIndex",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub content_document_index: Option<i64>,
    /// Type of a pseudo element node.
    #[serde(
        rename = "pseudoType",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub pseudo_type: Option<crate::protocol::dom::PseudoType>,
    /// Shadow root type.
    #[serde(
        rename = "shadowRootType",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub shadow_root_type: Option<crate::protocol::dom::ShadowRootType>,
    /// Whether this DOM node responds to mouse clicks. This includes nodes that
    /// have had click event listeners attached via JavaScript as well as anchor
    /// tags that naturally navigate when clicked.
    #[serde(
        rename = "isClickable",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub is_clickable: Option<bool>,
    /// Details of the node's event listeners, if any.
    #[serde(
        rename = "eventListeners",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub event_listeners: Option<Vec<crate::protocol::dom_debugger::EventListener>>,
    /// The selected url for nodes with a srcset attribute.
    #[serde(
        rename = "currentSourceURL",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub current_source_url: Option<String>,
    /// The url of the script (if any) that generates this node.
    #[serde(rename = "originURL", default, skip_serializing_if = "Option::is_none")]
    pub origin_url: Option<String>,
    /// Scroll offsets, set when this node is a Document.
    #[serde(
        rename = "scrollOffsetX",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub scroll_offset_x: Option<f64>,
    #[serde(
        rename = "scrollOffsetY",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub scroll_offset_y: Option<f64>,
}

/// Details of post layout rendered text positions. The exact layout should
/// not be regarded as stable and may change between versions.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct InlineTextBox {
    /// The bounding box in document coordinates. Note that scroll offset of the
    /// document is ignored.
    #[serde(rename = "boundingBox")]
    pub bounding_box: crate::protocol::dom::Rect,
    /// The starting index in characters, for this post layout textbox substring.
    /// Characters that would be represented as a surrogate pair in UTF-16 have
    /// length 2.
    #[serde(rename = "startCharacterIndex")]
    pub start_character_index: i64,
    /// The number of characters in this post layout textbox substring. Characters
    /// that would be represented as a surrogate pair in UTF-16 have length 2.
    #[serde(rename = "numCharacters")]
    pub num_characters: i64,
}

/// Details of an element in the DOM tree with a LayoutObject.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct LayoutTreeNode {
    /// The index of the related DOM node in the `domNodes` array returned by
    /// `getSnapshot`.
    #[serde(rename = "domNodeIndex")]
    pub dom_node_index: i64,
    /// The bounding box in document coordinates. Note that scroll offset of the
    /// document is ignored.
    #[serde(rename = "boundingBox")]
    pub bounding_box: crate::protocol::dom::Rect,
    /// Contents of the LayoutText, if any.
    #[serde(
        rename = "layoutText",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub layout_text: Option<String>,
    /// The post-layout inline text nodes, if any.
    #[serde(
        rename = "inlineTextNodes",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub inline_text_nodes: Option<Vec<InlineTextBox>>,
    /// Index into the `computedStyles` array returned by `getSnapshot`.
    #[serde(
        rename = "styleIndex",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub style_index: Option<i64>,
    /// Global paint order index, which is determined by the stacking order of the
    /// nodes. Nodes that are painted together will have the same index. Only
    /// provided if includePaintOrder in getSnapshot was true.
    #[serde(
        rename = "paintOrder",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub paint_order: Option<i64>,
    /// Set to true to indicate the element begins a new stacking context.
    #[serde(
        rename = "isStackingContext",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub is_stacking_context: Option<bool>,
}

/// A subset of the full ComputedStyle as defined by the request whitelist.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ComputedStyle {
    /// Name/value pairs of computed style properties.
    pub properties: Vec<NameValue>,
}

/// A name/value pair.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct NameValue {
    /// Attribute/property name.
    pub name: String,
    /// Attribute/property value.
    pub value: String,
}

/// Index of the string in the strings table.
pub type StringIndex = i64;

/// Index of the string in the strings table.
pub type ArrayOfStrings = Vec<StringIndex>;

/// Data that is only present on rare nodes.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RareStringData {
    pub index: Vec<i64>,
    pub value: Vec<StringIndex>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RareBooleanData {
    pub index: Vec<i64>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RareIntegerData {
    pub index: Vec<i64>,
    pub value: Vec<i64>,
}

pub type Rectangle = Vec<f64>;

/// Document snapshot.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DocumentSnapshot {
    /// Document URL that `Document` or `FrameOwner` node points to.
    #[serde(rename = "documentURL")]
    pub document_url: StringIndex,
    /// Document title.
    pub title: StringIndex,
    /// Base URL that `Document` or `FrameOwner` node uses for URL completion.
    #[serde(rename = "baseURL")]
    pub base_url: StringIndex,
    /// Contains the document's content language.
    #[serde(rename = "contentLanguage")]
    pub content_language: StringIndex,
    /// Contains the document's character set encoding.
    #[serde(rename = "encodingName")]
    pub encoding_name: StringIndex,
    /// `DocumentType` node's publicId.
    #[serde(rename = "publicId")]
    pub public_id: StringIndex,
    /// `DocumentType` node's systemId.
    #[serde(rename = "systemId")]
    pub system_id: StringIndex,
    /// Frame ID for frame owner elements and also for the document node.
    #[serde(rename = "frameId")]
    pub frame_id: StringIndex,
    /// A table with dom nodes.
    pub nodes: NodeTreeSnapshot,
    /// The nodes in the layout tree.
    pub layout: LayoutTreeSnapshot,
    /// The post-layout inline text nodes.
    #[serde(rename = "textBoxes")]
    pub text_boxes: TextBoxSnapshot,
    /// Horizontal scroll offset.
    #[serde(
        rename = "scrollOffsetX",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub scroll_offset_x: Option<f64>,
    /// Vertical scroll offset.
    #[serde(
        rename = "scrollOffsetY",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub scroll_offset_y: Option<f64>,
    /// Document content width.
    #[serde(
        rename = "contentWidth",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub content_width: Option<f64>,
    /// Document content height.
    #[serde(
        rename = "contentHeight",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub content_height: Option<f64>,
}

/// Table containing nodes.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct NodeTreeSnapshot {
    /// Parent node index.
    #[serde(
        rename = "parentIndex",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub parent_index: Option<Vec<i64>>,
    /// `Node`'s nodeType.
    #[serde(rename = "nodeType", default, skip_serializing_if = "Option::is_none")]
    pub node_type: Option<Vec<i64>>,
    /// Type of the shadow root the `Node` is in. String values are equal to the
    /// `ShadowRootType` enum.
    #[serde(
        rename = "shadowRootType",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub shadow_root_type: Option<RareStringData>,
    /// `Node`'s nodeName.
    #[serde(rename = "nodeName", default, skip_serializing_if = "Option::is_none")]
    pub node_name: Option<Vec<StringIndex>>,
    /// `Node`'s nodeValue.
    #[serde(rename = "nodeValue", default, skip_serializing_if = "Option::is_none")]
    pub node_value: Option<Vec<StringIndex>>,
    /// `Node`'s id, corresponds to DOM.Node.backendNodeId.
    #[serde(
        rename = "backendNodeId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub backend_node_id: Option<Vec<crate::protocol::dom::BackendNodeId>>,
    /// Attributes of an `Element` node. Flatten name, value pairs.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub attributes: Option<Vec<ArrayOfStrings>>,
    /// Only set for textarea elements, contains the text value.
    #[serde(rename = "textValue", default, skip_serializing_if = "Option::is_none")]
    pub text_value: Option<RareStringData>,
    /// Only set for input elements, contains the input's associated text value.
    #[serde(
        rename = "inputValue",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub input_value: Option<RareStringData>,
    /// Only set for radio and checkbox input elements, indicates if the element
    /// has been checked
    #[serde(
        rename = "inputChecked",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub input_checked: Option<RareBooleanData>,
    /// Only set for option elements, indicates if the element has been selected
    #[serde(
        rename = "optionSelected",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub option_selected: Option<RareBooleanData>,
    /// The index of the document in the list of the snapshot documents.
    #[serde(
        rename = "contentDocumentIndex",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub content_document_index: Option<RareIntegerData>,
    /// Type of a pseudo element node.
    #[serde(
        rename = "pseudoType",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub pseudo_type: Option<RareStringData>,
    /// Pseudo element identifier for this node. Only present if there is a valid
    /// pseudoType.
    #[serde(
        rename = "pseudoIdentifier",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub pseudo_identifier: Option<RareStringData>,
    /// Whether this DOM node responds to mouse clicks. This includes nodes that
    /// have had click event listeners attached via JavaScript as well as anchor
    /// tags that naturally navigate when clicked.
    #[serde(
        rename = "isClickable",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub is_clickable: Option<RareBooleanData>,
    /// The selected url for nodes with a srcset attribute.
    #[serde(
        rename = "currentSourceURL",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub current_source_url: Option<RareStringData>,
    /// The url of the script (if any) that generates this node.
    #[serde(rename = "originURL", default, skip_serializing_if = "Option::is_none")]
    pub origin_url: Option<RareStringData>,
}

/// Table of details of an element in the DOM tree with a LayoutObject.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct LayoutTreeSnapshot {
    /// Index of the corresponding node in the `NodeTreeSnapshot` array returned
    /// by `captureSnapshot`.
    #[serde(rename = "nodeIndex")]
    pub node_index: Vec<i64>,
    /// Array of indexes specifying computed style strings, filtered according to
    /// the `computedStyles` parameter passed to `captureSnapshot`.
    pub styles: Vec<ArrayOfStrings>,
    /// The absolute position bounding box.
    pub bounds: Vec<Rectangle>,
    /// Contents of the LayoutText, if any.
    pub text: Vec<StringIndex>,
    /// Stacking context information.
    #[serde(rename = "stackingContexts")]
    pub stacking_contexts: RareBooleanData,
    /// Global paint order index, which is determined by the stacking order of the
    /// nodes. Nodes that are painted together will have the same index. Only
    /// provided if includePaintOrder in captureSnapshot was true.
    #[serde(
        rename = "paintOrders",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub paint_orders: Option<Vec<i64>>,
    /// The offset rect of nodes. Only available when includeDOMRects is set to
    /// true
    #[serde(
        rename = "offsetRects",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub offset_rects: Option<Vec<Rectangle>>,
    /// The scroll rect of nodes. Only available when includeDOMRects is set to
    /// true
    #[serde(
        rename = "scrollRects",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub scroll_rects: Option<Vec<Rectangle>>,
    /// The client rect of nodes. Only available when includeDOMRects is set to
    /// true
    #[serde(
        rename = "clientRects",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub client_rects: Option<Vec<Rectangle>>,
    /// The list of background colors that are blended with colors of overlapping
    /// elements.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "blendedBackgroundColors",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub blended_background_colors: Option<Vec<StringIndex>>,
    /// The list of computed text opacities.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "textColorOpacities",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub text_color_opacities: Option<Vec<f64>>,
}

/// Table of details of the post layout rendered text positions. The exact
/// layout should not be regarded as stable and may change between versions.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct TextBoxSnapshot {
    /// Index of the layout tree node that owns this box collection.
    #[serde(rename = "layoutIndex")]
    pub layout_index: Vec<i64>,
    /// The absolute position bounding box.
    pub bounds: Vec<Rectangle>,
    /// The starting index in characters, for this post layout textbox substring.
    /// Characters that would be represented as a surrogate pair in UTF-16 have
    /// length 2.
    pub start: Vec<i64>,
    /// The number of characters in this post layout textbox substring. Characters
    /// that would be represented as a surrogate pair in UTF-16 have length 2.
    pub length: Vec<i64>,
}

/// Disables DOM snapshot agent for the given page.
///
/// Parameters of `DOMSnapshot.disable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}

impl crate::typed::Command for DisableParams {
    const METHOD: &'static str = "DOMSnapshot.disable";
    type Returns = crate::typed::NoReturns;
}

/// Enables DOM snapshot agent for the given page.
///
/// Parameters of `DOMSnapshot.enable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {}

impl crate::typed::Command for EnableParams {
    const METHOD: &'static str = "DOMSnapshot.enable";
    type Returns = crate::typed::NoReturns;
}

/// Returns a document snapshot, including the full DOM tree of the root node
/// (including iframes, template contents, and imported documents) in a
/// flattened array, as well as layout and white-listed computed style
/// information for the nodes. Shadow DOM in the returned DOM tree is
/// flattened.
///
/// Deprecated in the protocol.
///
/// Parameters of `DOMSnapshot.getSnapshot`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetSnapshotParams {
    /// Whitelist of computed styles to return.
    #[serde(rename = "computedStyleWhitelist")]
    pub computed_style_whitelist: Vec<String>,
    /// Whether or not to retrieve details of DOM listeners (default false).
    #[serde(
        rename = "includeEventListeners",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub include_event_listeners: Option<bool>,
    /// Whether to determine and include the paint order index of LayoutTreeNodes
    /// (default false).
    #[serde(
        rename = "includePaintOrder",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub include_paint_order: Option<bool>,
    /// Whether to include UA shadow tree in the snapshot (default false).
    #[serde(
        rename = "includeUserAgentShadowTree",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub include_user_agent_shadow_tree: Option<bool>,
}

/// What `DOMSnapshot.getSnapshot` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetSnapshotReturns {
    /// The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root
    /// document.
    #[serde(rename = "domNodes")]
    pub dom_nodes: Vec<DomNode>,
    /// The nodes in the layout tree.
    #[serde(rename = "layoutTreeNodes")]
    pub layout_tree_nodes: Vec<LayoutTreeNode>,
    /// Whitelisted ComputedStyle properties for each node in the layout tree.
    #[serde(rename = "computedStyles")]
    pub computed_styles: Vec<ComputedStyle>,
}

impl crate::typed::Command for GetSnapshotParams {
    const METHOD: &'static str = "DOMSnapshot.getSnapshot";
    type Returns = GetSnapshotReturns;
}

/// Returns a document snapshot, including the full DOM tree of the root node
/// (including iframes, template contents, and imported documents) in a
/// flattened array, as well as layout and white-listed computed style
/// information for the nodes. Shadow DOM in the returned DOM tree is
/// flattened.
///
/// Parameters of `DOMSnapshot.captureSnapshot`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CaptureSnapshotParams {
    /// Whitelist of computed styles to return.
    #[serde(rename = "computedStyles")]
    pub computed_styles: Vec<String>,
    /// Whether to include layout object paint orders into the snapshot.
    #[serde(
        rename = "includePaintOrder",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub include_paint_order: Option<bool>,
    /// Whether to include DOM rectangles (offsetRects, clientRects, scrollRects)
    /// into the snapshot
    #[serde(
        rename = "includeDOMRects",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub include_dom_rects: Option<bool>,
    /// Whether to include blended background colors in the snapshot (default:
    /// false). Blended background color is achieved by blending background colors
    /// of all elements that overlap with the current element.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "includeBlendedBackgroundColors",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub include_blended_background_colors: Option<bool>,
    /// Whether to include text color opacity in the snapshot (default: false). An
    /// element might have the opacity property set that affects the text color of
    /// the element. The final text color opacity is computed based on the opacity
    /// of all overlapping elements.
    ///
    /// Experimental: may change without notice.
    #[serde(
        rename = "includeTextColorOpacities",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub include_text_color_opacities: Option<bool>,
}

/// What `DOMSnapshot.captureSnapshot` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CaptureSnapshotReturns {
    /// The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root
    /// document.
    pub documents: Vec<DocumentSnapshot>,
    /// Shared string table that all string properties refer to with indexes.
    pub strings: Vec<String>,
}

impl crate::typed::Command for CaptureSnapshotParams {
    const METHOD: &'static str = "DOMSnapshot.captureSnapshot";
    type Returns = CaptureSnapshotReturns;
}