browser-commander 0.18.0

Universal browser automation library that supports multiple browser engines with a unified API
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
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
// @generated by scripts/generate-playwright-protocol.mjs from
// rust/protocol/playwright/*.yml. Do not edit by hand.

#![allow(clippy::all, missing_docs, unused_imports)]

use serde::{Deserialize, Serialize};

use super::*;
use crate::playwright::connection::{
    Binary, Channel, ChannelType, ObjectRef, ProtocolError, ProtocolEvent, Ref,
};

/// Initializer the driver sends when it creates a `ElementHandle`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleInitializer {}

/// Parameters of `ElementHandle.evalOnSelector` (Evaluate).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleEvalOnSelectorParams {
    #[serde(rename = "selector")]
    pub selector: String,
    #[serde(rename = "strict", default, skip_serializing_if = "Option::is_none")]
    pub strict: Option<bool>,
    #[serde(rename = "expression")]
    pub expression: String,
    #[serde(rename = "isFunction", default, skip_serializing_if = "Option::is_none")]
    pub is_function: Option<bool>,
    #[serde(rename = "arg")]
    pub arg: SerializedArgument,
}

/// Result of `ElementHandle.evalOnSelector` (Evaluate).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleEvalOnSelectorResult {
    #[serde(rename = "value")]
    pub value: SerializedValue,
}

/// Parameters of `ElementHandle.evalOnSelectorAll` (Evaluate).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleEvalOnSelectorAllParams {
    #[serde(rename = "selector")]
    pub selector: String,
    #[serde(rename = "expression")]
    pub expression: String,
    #[serde(rename = "isFunction", default, skip_serializing_if = "Option::is_none")]
    pub is_function: Option<bool>,
    #[serde(rename = "arg")]
    pub arg: SerializedArgument,
}

/// Result of `ElementHandle.evalOnSelectorAll` (Evaluate).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleEvalOnSelectorAllResult {
    #[serde(rename = "value")]
    pub value: SerializedValue,
}

/// Result of `ElementHandle.boundingBox` (Get bounding box).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleBoundingBoxResult {
    #[serde(rename = "value", default, skip_serializing_if = "Option::is_none")]
    pub value: Option<Rect>,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleCheckParamsScroll {
    #[default]
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "none")]
    None,
}

/// Parameters of `ElementHandle.check` (Check).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleCheckParams {
    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
    pub force: Option<bool>,
    #[serde(rename = "scroll", default, skip_serializing_if = "Option::is_none")]
    pub scroll: Option<ElementHandleCheckParamsScroll>,
    #[serde(rename = "position", default, skip_serializing_if = "Option::is_none")]
    pub position: Option<Point>,
    #[serde(rename = "trial", default, skip_serializing_if = "Option::is_none")]
    pub trial: Option<bool>,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleClickParamsScroll {
    #[default]
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "none")]
    None,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleClickParamsModifiers {
    #[default]
    #[serde(rename = "Alt")]
    Alt,
    #[serde(rename = "Control")]
    Control,
    #[serde(rename = "ControlOrMeta")]
    ControlOrMeta,
    #[serde(rename = "Meta")]
    Meta,
    #[serde(rename = "Shift")]
    Shift,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleClickParamsButton {
    #[default]
    #[serde(rename = "left")]
    Left,
    #[serde(rename = "right")]
    Right,
    #[serde(rename = "middle")]
    Middle,
}

/// Parameters of `ElementHandle.click` (Click).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleClickParams {
    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
    pub force: Option<bool>,
    #[serde(rename = "scroll", default, skip_serializing_if = "Option::is_none")]
    pub scroll: Option<ElementHandleClickParamsScroll>,
    #[serde(rename = "noWaitAfter", default, skip_serializing_if = "Option::is_none")]
    pub no_wait_after: Option<bool>,
    #[serde(rename = "modifiers", default, skip_serializing_if = "Option::is_none")]
    pub modifiers: Option<Vec<ElementHandleClickParamsModifiers>>,
    #[serde(rename = "position", default, skip_serializing_if = "Option::is_none")]
    pub position: Option<Point>,
    #[serde(rename = "delay", default, skip_serializing_if = "Option::is_none")]
    pub delay: Option<f64>,
    #[serde(rename = "button", default, skip_serializing_if = "Option::is_none")]
    pub button: Option<ElementHandleClickParamsButton>,
    #[serde(rename = "clickCount", default, skip_serializing_if = "Option::is_none")]
    pub click_count: Option<i64>,
    #[serde(rename = "trial", default, skip_serializing_if = "Option::is_none")]
    pub trial: Option<bool>,
    #[serde(rename = "steps", default, skip_serializing_if = "Option::is_none")]
    pub steps: Option<i64>,
}

/// Result of `ElementHandle.contentFrame` (Get content frame).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleContentFrameResult {
    #[serde(rename = "frame", default, skip_serializing_if = "Option::is_none")]
    pub frame: Option<Ref<Frame>>,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleDblclickParamsScroll {
    #[default]
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "none")]
    None,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleDblclickParamsModifiers {
    #[default]
    #[serde(rename = "Alt")]
    Alt,
    #[serde(rename = "Control")]
    Control,
    #[serde(rename = "ControlOrMeta")]
    ControlOrMeta,
    #[serde(rename = "Meta")]
    Meta,
    #[serde(rename = "Shift")]
    Shift,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleDblclickParamsButton {
    #[default]
    #[serde(rename = "left")]
    Left,
    #[serde(rename = "right")]
    Right,
    #[serde(rename = "middle")]
    Middle,
}

/// Parameters of `ElementHandle.dblclick` (Double click).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleDblclickParams {
    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
    pub force: Option<bool>,
    #[serde(rename = "scroll", default, skip_serializing_if = "Option::is_none")]
    pub scroll: Option<ElementHandleDblclickParamsScroll>,
    #[serde(rename = "modifiers", default, skip_serializing_if = "Option::is_none")]
    pub modifiers: Option<Vec<ElementHandleDblclickParamsModifiers>>,
    #[serde(rename = "position", default, skip_serializing_if = "Option::is_none")]
    pub position: Option<Point>,
    #[serde(rename = "delay", default, skip_serializing_if = "Option::is_none")]
    pub delay: Option<f64>,
    #[serde(rename = "button", default, skip_serializing_if = "Option::is_none")]
    pub button: Option<ElementHandleDblclickParamsButton>,
    #[serde(rename = "trial", default, skip_serializing_if = "Option::is_none")]
    pub trial: Option<bool>,
    #[serde(rename = "steps", default, skip_serializing_if = "Option::is_none")]
    pub steps: Option<i64>,
}

/// Parameters of `ElementHandle.dispatchEvent` (Dispatch event).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleDispatchEventParams {
    #[serde(rename = "type")]
    pub r#type: String,
    #[serde(rename = "eventInit")]
    pub event_init: SerializedArgument,
}

/// Parameters of `ElementHandle.fill` (Fill "{value}").
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleFillParams {
    #[serde(rename = "value")]
    pub value: String,
    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
    pub force: Option<bool>,
}

/// Parameters of `ElementHandle.getAttribute` (Get attribute).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleGetAttributeParams {
    #[serde(rename = "name")]
    pub name: String,
}

/// Result of `ElementHandle.getAttribute` (Get attribute).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleGetAttributeResult {
    #[serde(rename = "value", default, skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleHoverParamsScroll {
    #[default]
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "none")]
    None,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleHoverParamsModifiers {
    #[default]
    #[serde(rename = "Alt")]
    Alt,
    #[serde(rename = "Control")]
    Control,
    #[serde(rename = "ControlOrMeta")]
    ControlOrMeta,
    #[serde(rename = "Meta")]
    Meta,
    #[serde(rename = "Shift")]
    Shift,
}

/// Parameters of `ElementHandle.hover` (Hover).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleHoverParams {
    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
    pub force: Option<bool>,
    #[serde(rename = "scroll", default, skip_serializing_if = "Option::is_none")]
    pub scroll: Option<ElementHandleHoverParamsScroll>,
    #[serde(rename = "modifiers", default, skip_serializing_if = "Option::is_none")]
    pub modifiers: Option<Vec<ElementHandleHoverParamsModifiers>>,
    #[serde(rename = "position", default, skip_serializing_if = "Option::is_none")]
    pub position: Option<Point>,
    #[serde(rename = "trial", default, skip_serializing_if = "Option::is_none")]
    pub trial: Option<bool>,
}

/// Result of `ElementHandle.innerHTML` (Get HTML).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleInnerHTMLResult {
    #[serde(rename = "value")]
    pub value: String,
}

/// Result of `ElementHandle.innerText` (Get inner text).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleInnerTextResult {
    #[serde(rename = "value")]
    pub value: String,
}

/// Result of `ElementHandle.inputValue` (Get input value).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleInputValueResult {
    #[serde(rename = "value")]
    pub value: String,
}

/// Result of `ElementHandle.isChecked` (Is checked).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleIsCheckedResult {
    #[serde(rename = "value")]
    pub value: bool,
}

/// Result of `ElementHandle.isDisabled` (Is disabled).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleIsDisabledResult {
    #[serde(rename = "value")]
    pub value: bool,
}

/// Result of `ElementHandle.isEditable` (Is editable).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleIsEditableResult {
    #[serde(rename = "value")]
    pub value: bool,
}

/// Result of `ElementHandle.isEnabled` (Is enabled).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleIsEnabledResult {
    #[serde(rename = "value")]
    pub value: bool,
}

/// Result of `ElementHandle.isHidden` (Is hidden).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleIsHiddenResult {
    #[serde(rename = "value")]
    pub value: bool,
}

/// Result of `ElementHandle.isVisible` (Is visible).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleIsVisibleResult {
    #[serde(rename = "value")]
    pub value: bool,
}

/// Result of `ElementHandle.ownerFrame` (Get owner frame).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleOwnerFrameResult {
    #[serde(rename = "frame", default, skip_serializing_if = "Option::is_none")]
    pub frame: Option<Ref<Frame>>,
}

/// Parameters of `ElementHandle.press` (Press "{key}").
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandlePressParams {
    #[serde(rename = "key")]
    pub key: String,
    #[serde(rename = "delay", default, skip_serializing_if = "Option::is_none")]
    pub delay: Option<f64>,
    #[serde(rename = "noWaitAfter", default, skip_serializing_if = "Option::is_none")]
    pub no_wait_after: Option<bool>,
}

/// Parameters of `ElementHandle.querySelector` (Query selector).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleQuerySelectorParams {
    #[serde(rename = "selector")]
    pub selector: String,
    #[serde(rename = "strict", default, skip_serializing_if = "Option::is_none")]
    pub strict: Option<bool>,
}

/// Result of `ElementHandle.querySelector` (Query selector).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleQuerySelectorResult {
    #[serde(rename = "element", default, skip_serializing_if = "Option::is_none")]
    pub element: Option<Ref<ElementHandle>>,
}

/// Parameters of `ElementHandle.querySelectorAll` (Query selector all).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleQuerySelectorAllParams {
    #[serde(rename = "selector")]
    pub selector: String,
}

/// Result of `ElementHandle.querySelectorAll` (Query selector all).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleQuerySelectorAllResult {
    #[serde(rename = "elements")]
    pub elements: Vec<Ref<ElementHandle>>,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleScreenshotParamsType {
    #[default]
    #[serde(rename = "png")]
    Png,
    #[serde(rename = "jpeg")]
    Jpeg,
    #[serde(rename = "webp")]
    Webp,
}

/// Parameters of `ElementHandle.screenshot` (Screenshot).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleScreenshotParams {
    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
    pub r#type: Option<ElementHandleScreenshotParamsType>,
    #[serde(rename = "quality", default, skip_serializing_if = "Option::is_none")]
    pub quality: Option<i64>,
    /// Properties of the `CommonScreenshotOptions` mixin.
    #[serde(flatten)]
    pub common_screenshot_options: CommonScreenshotOptions,
}

/// Result of `ElementHandle.screenshot` (Screenshot).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleScreenshotResult {
    #[serde(rename = "binary")]
    pub binary: Binary,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleSelectOptionParamsOptions {
    #[serde(rename = "valueOrLabel", default, skip_serializing_if = "Option::is_none")]
    pub value_or_label: Option<String>,
    #[serde(rename = "value", default, skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,
    #[serde(rename = "label", default, skip_serializing_if = "Option::is_none")]
    pub label: Option<String>,
    #[serde(rename = "index", default, skip_serializing_if = "Option::is_none")]
    pub index: Option<i64>,
}

/// Parameters of `ElementHandle.selectOption` (Select option).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleSelectOptionParams {
    #[serde(rename = "elements", default, skip_serializing_if = "Option::is_none")]
    pub elements: Option<Vec<Ref<ElementHandle>>>,
    #[serde(rename = "options", default, skip_serializing_if = "Option::is_none")]
    pub options: Option<Vec<ElementHandleSelectOptionParamsOptions>>,
    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
    pub force: Option<bool>,
}

/// Result of `ElementHandle.selectOption` (Select option).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleSelectOptionResult {
    #[serde(rename = "values")]
    pub values: Vec<String>,
}

/// Parameters of `ElementHandle.selectText` (Select text).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleSelectTextParams {
    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
    pub force: Option<bool>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleSetInputFilesParamsPayloads {
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
    #[serde(rename = "buffer")]
    pub buffer: Binary,
}

/// Parameters of `ElementHandle.setInputFiles` (Set input files).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleSetInputFilesParams {
    #[serde(rename = "payloads", default, skip_serializing_if = "Option::is_none")]
    pub payloads: Option<Vec<ElementHandleSetInputFilesParamsPayloads>>,
    #[serde(rename = "localDirectory", default, skip_serializing_if = "Option::is_none")]
    pub local_directory: Option<String>,
    #[serde(rename = "directoryStream", default, skip_serializing_if = "Option::is_none")]
    pub directory_stream: Option<Ref<WritableStream>>,
    #[serde(rename = "localPaths", default, skip_serializing_if = "Option::is_none")]
    pub local_paths: Option<Vec<String>>,
    #[serde(rename = "streams", default, skip_serializing_if = "Option::is_none")]
    pub streams: Option<Vec<Ref<WritableStream>>>,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleTapParamsScroll {
    #[default]
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "none")]
    None,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleTapParamsModifiers {
    #[default]
    #[serde(rename = "Alt")]
    Alt,
    #[serde(rename = "Control")]
    Control,
    #[serde(rename = "ControlOrMeta")]
    ControlOrMeta,
    #[serde(rename = "Meta")]
    Meta,
    #[serde(rename = "Shift")]
    Shift,
}

/// Parameters of `ElementHandle.tap` (Tap).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleTapParams {
    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
    pub force: Option<bool>,
    #[serde(rename = "scroll", default, skip_serializing_if = "Option::is_none")]
    pub scroll: Option<ElementHandleTapParamsScroll>,
    #[serde(rename = "modifiers", default, skip_serializing_if = "Option::is_none")]
    pub modifiers: Option<Vec<ElementHandleTapParamsModifiers>>,
    #[serde(rename = "position", default, skip_serializing_if = "Option::is_none")]
    pub position: Option<Point>,
    #[serde(rename = "trial", default, skip_serializing_if = "Option::is_none")]
    pub trial: Option<bool>,
}

/// Result of `ElementHandle.textContent` (Get text content).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleTextContentResult {
    #[serde(rename = "value", default, skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,
}

/// Parameters of `ElementHandle.type` (Type).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleTypeParams {
    #[serde(rename = "text")]
    pub text: String,
    #[serde(rename = "delay", default, skip_serializing_if = "Option::is_none")]
    pub delay: Option<f64>,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleUncheckParamsScroll {
    #[default]
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "none")]
    None,
}

/// Parameters of `ElementHandle.uncheck` (Uncheck).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleUncheckParams {
    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
    pub force: Option<bool>,
    #[serde(rename = "scroll", default, skip_serializing_if = "Option::is_none")]
    pub scroll: Option<ElementHandleUncheckParamsScroll>,
    #[serde(rename = "position", default, skip_serializing_if = "Option::is_none")]
    pub position: Option<Point>,
    #[serde(rename = "trial", default, skip_serializing_if = "Option::is_none")]
    pub trial: Option<bool>,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleWaitForElementStateParamsState {
    #[default]
    #[serde(rename = "visible")]
    Visible,
    #[serde(rename = "hidden")]
    Hidden,
    #[serde(rename = "stable")]
    Stable,
    #[serde(rename = "enabled")]
    Enabled,
    #[serde(rename = "disabled")]
    Disabled,
    #[serde(rename = "editable")]
    Editable,
}

/// Parameters of `ElementHandle.waitForElementState` (Wait for state).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleWaitForElementStateParams {
    #[serde(rename = "state")]
    pub state: ElementHandleWaitForElementStateParamsState,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ElementHandleWaitForSelectorParamsState {
    #[default]
    #[serde(rename = "attached")]
    Attached,
    #[serde(rename = "detached")]
    Detached,
    #[serde(rename = "visible")]
    Visible,
    #[serde(rename = "hidden")]
    Hidden,
}

/// Parameters of `ElementHandle.waitForSelector` (Wait for selector).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleWaitForSelectorParams {
    #[serde(rename = "selector")]
    pub selector: String,
    #[serde(rename = "strict", default, skip_serializing_if = "Option::is_none")]
    pub strict: Option<bool>,
    #[serde(rename = "state", default, skip_serializing_if = "Option::is_none")]
    pub state: Option<ElementHandleWaitForSelectorParamsState>,
}

/// Result of `ElementHandle.waitForSelector` (Wait for selector).
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ElementHandleWaitForSelectorResult {
    #[serde(rename = "element", default, skip_serializing_if = "Option::is_none")]
    pub element: Option<Ref<ElementHandle>>,
}

/// Events a `ElementHandle` channel can emit.
#[derive(Debug, Clone, PartialEq)]
pub enum ElementHandleEvent {
    /// `JSHandle.previewUpdated`
    PreviewUpdated(JSHandlePreviewUpdatedEventParams),
    /// An event this binding does not know (a newer driver).
    Unknown {
        /// Event name.
        method: String,
        /// Raw event parameters.
        params: serde_json::Value,
    },
}

impl ProtocolEvent for ElementHandleEvent {
    fn parse(method: &str, params: serde_json::Value) -> Result<Self, serde_json::Error> {
        match method {
            "previewUpdated" => Ok(Self::PreviewUpdated(serde_json::from_value(params)?)),
            _ => Ok(Self::Unknown { method: method.to_string(), params }),
        }
    }
}

/// Channel for the `ElementHandle` interface (`handles.yml`).
#[derive(Debug, Clone)]
pub struct ElementHandle {
    channel: Channel,
}

impl ChannelType for ElementHandle {
    const INTERFACE: &'static str = "ElementHandle";
    type Initializer = ElementHandleInitializer;
    type Event = ElementHandleEvent;

    fn accepts(interface: &str) -> bool {
        matches!(interface, "ElementHandle")
    }

    fn from_channel(channel: Channel) -> Self {
        Self { channel }
    }

    fn channel(&self) -> &Channel {
        &self.channel
    }
}

impl ElementHandle {
    /// `JSHandle.dispose` (internal).
    pub async fn dispose(&self) -> Result<(), ProtocolError> {
        self.channel.send_no_result("dispose", &serde_json::json!({})).await
    }

    /// `JSHandle.evaluateExpression` ("Evaluate").
    pub async fn evaluate_expression(&self, params: JSHandleEvaluateExpressionParams) -> Result<JSHandleEvaluateExpressionResult, ProtocolError> {
        self.channel.send("evaluateExpression", &params).await
    }

    /// `JSHandle.evaluateExpressionHandle` ("Evaluate").
    pub async fn evaluate_expression_handle(&self, params: JSHandleEvaluateExpressionHandleParams) -> Result<JSHandleEvaluateExpressionHandleResult, ProtocolError> {
        self.channel.send("evaluateExpressionHandle", &params).await
    }

    /// `JSHandle.getPropertyList` ("Get property list").
    pub async fn get_property_list(&self) -> Result<JSHandleGetPropertyListResult, ProtocolError> {
        self.channel.send("getPropertyList", &serde_json::json!({})).await
    }

    /// `JSHandle.getProperty` ("Get JS property").
    pub async fn get_property(&self, params: JSHandleGetPropertyParams) -> Result<JSHandleGetPropertyResult, ProtocolError> {
        self.channel.send("getProperty", &params).await
    }

    /// `JSHandle.jsonValue` ("Get JSON value").
    pub async fn json_value(&self) -> Result<JSHandleJsonValueResult, ProtocolError> {
        self.channel.send("jsonValue", &serde_json::json!({})).await
    }

    /// `ElementHandle.evalOnSelector` ("Evaluate").
    pub async fn eval_on_selector(&self, params: ElementHandleEvalOnSelectorParams) -> Result<ElementHandleEvalOnSelectorResult, ProtocolError> {
        self.channel.send("evalOnSelector", &params).await
    }

    /// `ElementHandle.evalOnSelectorAll` ("Evaluate").
    pub async fn eval_on_selector_all(&self, params: ElementHandleEvalOnSelectorAllParams) -> Result<ElementHandleEvalOnSelectorAllResult, ProtocolError> {
        self.channel.send("evalOnSelectorAll", &params).await
    }

    /// `ElementHandle.boundingBox` ("Get bounding box").
    pub async fn bounding_box(&self) -> Result<ElementHandleBoundingBoxResult, ProtocolError> {
        self.channel.send("boundingBox", &serde_json::json!({})).await
    }

    /// `ElementHandle.check` ("Check").
    pub async fn check(&self, params: ElementHandleCheckParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("check", &params).await
    }

    /// `ElementHandle.click` ("Click").
    pub async fn click(&self, params: ElementHandleClickParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("click", &params).await
    }

    /// `ElementHandle.contentFrame` ("Get content frame").
    pub async fn content_frame(&self) -> Result<ElementHandleContentFrameResult, ProtocolError> {
        self.channel.send("contentFrame", &serde_json::json!({})).await
    }

    /// `ElementHandle.dblclick` ("Double click").
    pub async fn dblclick(&self, params: ElementHandleDblclickParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("dblclick", &params).await
    }

    /// `ElementHandle.dispatchEvent` ("Dispatch event").
    pub async fn dispatch_event(&self, params: ElementHandleDispatchEventParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("dispatchEvent", &params).await
    }

    /// `ElementHandle.fill` ("Fill "{value}"").
    pub async fn fill(&self, params: ElementHandleFillParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("fill", &params).await
    }

    /// `ElementHandle.focus` ("Focus").
    pub async fn focus(&self) -> Result<(), ProtocolError> {
        self.channel.send_no_result("focus", &serde_json::json!({})).await
    }

    /// `ElementHandle.getAttribute` ("Get attribute").
    pub async fn get_attribute(&self, params: ElementHandleGetAttributeParams) -> Result<ElementHandleGetAttributeResult, ProtocolError> {
        self.channel.send("getAttribute", &params).await
    }

    /// `ElementHandle.hover` ("Hover").
    pub async fn hover(&self, params: ElementHandleHoverParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("hover", &params).await
    }

    /// `ElementHandle.innerHTML` ("Get HTML").
    pub async fn inner_html(&self) -> Result<ElementHandleInnerHTMLResult, ProtocolError> {
        self.channel.send("innerHTML", &serde_json::json!({})).await
    }

    /// `ElementHandle.innerText` ("Get inner text").
    pub async fn inner_text(&self) -> Result<ElementHandleInnerTextResult, ProtocolError> {
        self.channel.send("innerText", &serde_json::json!({})).await
    }

    /// `ElementHandle.inputValue` ("Get input value").
    pub async fn input_value(&self) -> Result<ElementHandleInputValueResult, ProtocolError> {
        self.channel.send("inputValue", &serde_json::json!({})).await
    }

    /// `ElementHandle.isChecked` ("Is checked").
    pub async fn is_checked(&self) -> Result<ElementHandleIsCheckedResult, ProtocolError> {
        self.channel.send("isChecked", &serde_json::json!({})).await
    }

    /// `ElementHandle.isDisabled` ("Is disabled").
    pub async fn is_disabled(&self) -> Result<ElementHandleIsDisabledResult, ProtocolError> {
        self.channel.send("isDisabled", &serde_json::json!({})).await
    }

    /// `ElementHandle.isEditable` ("Is editable").
    pub async fn is_editable(&self) -> Result<ElementHandleIsEditableResult, ProtocolError> {
        self.channel.send("isEditable", &serde_json::json!({})).await
    }

    /// `ElementHandle.isEnabled` ("Is enabled").
    pub async fn is_enabled(&self) -> Result<ElementHandleIsEnabledResult, ProtocolError> {
        self.channel.send("isEnabled", &serde_json::json!({})).await
    }

    /// `ElementHandle.isHidden` ("Is hidden").
    pub async fn is_hidden(&self) -> Result<ElementHandleIsHiddenResult, ProtocolError> {
        self.channel.send("isHidden", &serde_json::json!({})).await
    }

    /// `ElementHandle.isVisible` ("Is visible").
    pub async fn is_visible(&self) -> Result<ElementHandleIsVisibleResult, ProtocolError> {
        self.channel.send("isVisible", &serde_json::json!({})).await
    }

    /// `ElementHandle.ownerFrame` ("Get owner frame").
    pub async fn owner_frame(&self) -> Result<ElementHandleOwnerFrameResult, ProtocolError> {
        self.channel.send("ownerFrame", &serde_json::json!({})).await
    }

    /// `ElementHandle.press` ("Press "{key}"").
    pub async fn press(&self, params: ElementHandlePressParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("press", &params).await
    }

    /// `ElementHandle.querySelector` ("Query selector").
    pub async fn query_selector(&self, params: ElementHandleQuerySelectorParams) -> Result<ElementHandleQuerySelectorResult, ProtocolError> {
        self.channel.send("querySelector", &params).await
    }

    /// `ElementHandle.querySelectorAll` ("Query selector all").
    pub async fn query_selector_all(&self, params: ElementHandleQuerySelectorAllParams) -> Result<ElementHandleQuerySelectorAllResult, ProtocolError> {
        self.channel.send("querySelectorAll", &params).await
    }

    /// `ElementHandle.screenshot` ("Screenshot").
    pub async fn screenshot(&self, params: ElementHandleScreenshotParams) -> Result<ElementHandleScreenshotResult, ProtocolError> {
        self.channel.send("screenshot", &params).await
    }

    /// `ElementHandle.scrollIntoViewIfNeeded` ("Scroll into view").
    pub async fn scroll_into_view_if_needed(&self) -> Result<(), ProtocolError> {
        self.channel.send_no_result("scrollIntoViewIfNeeded", &serde_json::json!({})).await
    }

    /// `ElementHandle.selectOption` ("Select option").
    pub async fn select_option(&self, params: ElementHandleSelectOptionParams) -> Result<ElementHandleSelectOptionResult, ProtocolError> {
        self.channel.send("selectOption", &params).await
    }

    /// `ElementHandle.selectText` ("Select text").
    pub async fn select_text(&self, params: ElementHandleSelectTextParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("selectText", &params).await
    }

    /// `ElementHandle.setInputFiles` ("Set input files").
    pub async fn set_input_files(&self, params: ElementHandleSetInputFilesParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("setInputFiles", &params).await
    }

    /// `ElementHandle.tap` ("Tap").
    pub async fn tap(&self, params: ElementHandleTapParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("tap", &params).await
    }

    /// `ElementHandle.textContent` ("Get text content").
    pub async fn text_content(&self) -> Result<ElementHandleTextContentResult, ProtocolError> {
        self.channel.send("textContent", &serde_json::json!({})).await
    }

    /// `ElementHandle.type` ("Type").
    pub async fn r#type(&self, params: ElementHandleTypeParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("type", &params).await
    }

    /// `ElementHandle.uncheck` ("Uncheck").
    pub async fn uncheck(&self, params: ElementHandleUncheckParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("uncheck", &params).await
    }

    /// `ElementHandle.waitForElementState` ("Wait for state").
    pub async fn wait_for_element_state(&self, params: ElementHandleWaitForElementStateParams) -> Result<(), ProtocolError> {
        self.channel.send_no_result("waitForElementState", &params).await
    }

    /// `ElementHandle.waitForSelector` ("Wait for selector").
    pub async fn wait_for_selector(&self, params: ElementHandleWaitForSelectorParams) -> Result<ElementHandleWaitForSelectorResult, ProtocolError> {
        self.channel.send("waitForSelector", &params).await
    }
}