Skip to main content

browser_commander/playwright/protocol/
element_handle.rs

1// @generated by scripts/generate-playwright-protocol.mjs from
2// rust/protocol/playwright/*.yml. Do not edit by hand.
3
4#![allow(clippy::all, missing_docs, unused_imports)]
5
6use serde::{Deserialize, Serialize};
7
8use super::*;
9use crate::playwright::connection::{
10    Binary, Channel, ChannelType, ObjectRef, ProtocolError, ProtocolEvent, Ref,
11};
12
13/// Initializer the driver sends when it creates a `ElementHandle`.
14#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
15pub struct ElementHandleInitializer {}
16
17/// Parameters of `ElementHandle.evalOnSelector` (Evaluate).
18#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
19pub struct ElementHandleEvalOnSelectorParams {
20    #[serde(rename = "selector")]
21    pub selector: String,
22    #[serde(rename = "strict", default, skip_serializing_if = "Option::is_none")]
23    pub strict: Option<bool>,
24    #[serde(rename = "expression")]
25    pub expression: String,
26    #[serde(rename = "isFunction", default, skip_serializing_if = "Option::is_none")]
27    pub is_function: Option<bool>,
28    #[serde(rename = "arg")]
29    pub arg: SerializedArgument,
30}
31
32/// Result of `ElementHandle.evalOnSelector` (Evaluate).
33#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
34pub struct ElementHandleEvalOnSelectorResult {
35    #[serde(rename = "value")]
36    pub value: SerializedValue,
37}
38
39/// Parameters of `ElementHandle.evalOnSelectorAll` (Evaluate).
40#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
41pub struct ElementHandleEvalOnSelectorAllParams {
42    #[serde(rename = "selector")]
43    pub selector: String,
44    #[serde(rename = "expression")]
45    pub expression: String,
46    #[serde(rename = "isFunction", default, skip_serializing_if = "Option::is_none")]
47    pub is_function: Option<bool>,
48    #[serde(rename = "arg")]
49    pub arg: SerializedArgument,
50}
51
52/// Result of `ElementHandle.evalOnSelectorAll` (Evaluate).
53#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
54pub struct ElementHandleEvalOnSelectorAllResult {
55    #[serde(rename = "value")]
56    pub value: SerializedValue,
57}
58
59/// Result of `ElementHandle.boundingBox` (Get bounding box).
60#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
61pub struct ElementHandleBoundingBoxResult {
62    #[serde(rename = "value", default, skip_serializing_if = "Option::is_none")]
63    pub value: Option<Rect>,
64}
65
66#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
67pub enum ElementHandleCheckParamsScroll {
68    #[default]
69    #[serde(rename = "auto")]
70    Auto,
71    #[serde(rename = "none")]
72    None,
73}
74
75/// Parameters of `ElementHandle.check` (Check).
76#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
77pub struct ElementHandleCheckParams {
78    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
79    pub force: Option<bool>,
80    #[serde(rename = "scroll", default, skip_serializing_if = "Option::is_none")]
81    pub scroll: Option<ElementHandleCheckParamsScroll>,
82    #[serde(rename = "position", default, skip_serializing_if = "Option::is_none")]
83    pub position: Option<Point>,
84    #[serde(rename = "trial", default, skip_serializing_if = "Option::is_none")]
85    pub trial: Option<bool>,
86}
87
88#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
89pub enum ElementHandleClickParamsScroll {
90    #[default]
91    #[serde(rename = "auto")]
92    Auto,
93    #[serde(rename = "none")]
94    None,
95}
96
97#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
98pub enum ElementHandleClickParamsModifiers {
99    #[default]
100    #[serde(rename = "Alt")]
101    Alt,
102    #[serde(rename = "Control")]
103    Control,
104    #[serde(rename = "ControlOrMeta")]
105    ControlOrMeta,
106    #[serde(rename = "Meta")]
107    Meta,
108    #[serde(rename = "Shift")]
109    Shift,
110}
111
112#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
113pub enum ElementHandleClickParamsButton {
114    #[default]
115    #[serde(rename = "left")]
116    Left,
117    #[serde(rename = "right")]
118    Right,
119    #[serde(rename = "middle")]
120    Middle,
121}
122
123/// Parameters of `ElementHandle.click` (Click).
124#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
125pub struct ElementHandleClickParams {
126    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
127    pub force: Option<bool>,
128    #[serde(rename = "scroll", default, skip_serializing_if = "Option::is_none")]
129    pub scroll: Option<ElementHandleClickParamsScroll>,
130    #[serde(rename = "noWaitAfter", default, skip_serializing_if = "Option::is_none")]
131    pub no_wait_after: Option<bool>,
132    #[serde(rename = "modifiers", default, skip_serializing_if = "Option::is_none")]
133    pub modifiers: Option<Vec<ElementHandleClickParamsModifiers>>,
134    #[serde(rename = "position", default, skip_serializing_if = "Option::is_none")]
135    pub position: Option<Point>,
136    #[serde(rename = "delay", default, skip_serializing_if = "Option::is_none")]
137    pub delay: Option<f64>,
138    #[serde(rename = "button", default, skip_serializing_if = "Option::is_none")]
139    pub button: Option<ElementHandleClickParamsButton>,
140    #[serde(rename = "clickCount", default, skip_serializing_if = "Option::is_none")]
141    pub click_count: Option<i64>,
142    #[serde(rename = "trial", default, skip_serializing_if = "Option::is_none")]
143    pub trial: Option<bool>,
144    #[serde(rename = "steps", default, skip_serializing_if = "Option::is_none")]
145    pub steps: Option<i64>,
146}
147
148/// Result of `ElementHandle.contentFrame` (Get content frame).
149#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
150pub struct ElementHandleContentFrameResult {
151    #[serde(rename = "frame", default, skip_serializing_if = "Option::is_none")]
152    pub frame: Option<Ref<Frame>>,
153}
154
155#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
156pub enum ElementHandleDblclickParamsScroll {
157    #[default]
158    #[serde(rename = "auto")]
159    Auto,
160    #[serde(rename = "none")]
161    None,
162}
163
164#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
165pub enum ElementHandleDblclickParamsModifiers {
166    #[default]
167    #[serde(rename = "Alt")]
168    Alt,
169    #[serde(rename = "Control")]
170    Control,
171    #[serde(rename = "ControlOrMeta")]
172    ControlOrMeta,
173    #[serde(rename = "Meta")]
174    Meta,
175    #[serde(rename = "Shift")]
176    Shift,
177}
178
179#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
180pub enum ElementHandleDblclickParamsButton {
181    #[default]
182    #[serde(rename = "left")]
183    Left,
184    #[serde(rename = "right")]
185    Right,
186    #[serde(rename = "middle")]
187    Middle,
188}
189
190/// Parameters of `ElementHandle.dblclick` (Double click).
191#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
192pub struct ElementHandleDblclickParams {
193    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
194    pub force: Option<bool>,
195    #[serde(rename = "scroll", default, skip_serializing_if = "Option::is_none")]
196    pub scroll: Option<ElementHandleDblclickParamsScroll>,
197    #[serde(rename = "modifiers", default, skip_serializing_if = "Option::is_none")]
198    pub modifiers: Option<Vec<ElementHandleDblclickParamsModifiers>>,
199    #[serde(rename = "position", default, skip_serializing_if = "Option::is_none")]
200    pub position: Option<Point>,
201    #[serde(rename = "delay", default, skip_serializing_if = "Option::is_none")]
202    pub delay: Option<f64>,
203    #[serde(rename = "button", default, skip_serializing_if = "Option::is_none")]
204    pub button: Option<ElementHandleDblclickParamsButton>,
205    #[serde(rename = "trial", default, skip_serializing_if = "Option::is_none")]
206    pub trial: Option<bool>,
207    #[serde(rename = "steps", default, skip_serializing_if = "Option::is_none")]
208    pub steps: Option<i64>,
209}
210
211/// Parameters of `ElementHandle.dispatchEvent` (Dispatch event).
212#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
213pub struct ElementHandleDispatchEventParams {
214    #[serde(rename = "type")]
215    pub r#type: String,
216    #[serde(rename = "eventInit")]
217    pub event_init: SerializedArgument,
218}
219
220/// Parameters of `ElementHandle.fill` (Fill "{value}").
221#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
222pub struct ElementHandleFillParams {
223    #[serde(rename = "value")]
224    pub value: String,
225    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
226    pub force: Option<bool>,
227}
228
229/// Parameters of `ElementHandle.getAttribute` (Get attribute).
230#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
231pub struct ElementHandleGetAttributeParams {
232    #[serde(rename = "name")]
233    pub name: String,
234}
235
236/// Result of `ElementHandle.getAttribute` (Get attribute).
237#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
238pub struct ElementHandleGetAttributeResult {
239    #[serde(rename = "value", default, skip_serializing_if = "Option::is_none")]
240    pub value: Option<String>,
241}
242
243#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
244pub enum ElementHandleHoverParamsScroll {
245    #[default]
246    #[serde(rename = "auto")]
247    Auto,
248    #[serde(rename = "none")]
249    None,
250}
251
252#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
253pub enum ElementHandleHoverParamsModifiers {
254    #[default]
255    #[serde(rename = "Alt")]
256    Alt,
257    #[serde(rename = "Control")]
258    Control,
259    #[serde(rename = "ControlOrMeta")]
260    ControlOrMeta,
261    #[serde(rename = "Meta")]
262    Meta,
263    #[serde(rename = "Shift")]
264    Shift,
265}
266
267/// Parameters of `ElementHandle.hover` (Hover).
268#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
269pub struct ElementHandleHoverParams {
270    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
271    pub force: Option<bool>,
272    #[serde(rename = "scroll", default, skip_serializing_if = "Option::is_none")]
273    pub scroll: Option<ElementHandleHoverParamsScroll>,
274    #[serde(rename = "modifiers", default, skip_serializing_if = "Option::is_none")]
275    pub modifiers: Option<Vec<ElementHandleHoverParamsModifiers>>,
276    #[serde(rename = "position", default, skip_serializing_if = "Option::is_none")]
277    pub position: Option<Point>,
278    #[serde(rename = "trial", default, skip_serializing_if = "Option::is_none")]
279    pub trial: Option<bool>,
280}
281
282/// Result of `ElementHandle.innerHTML` (Get HTML).
283#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
284pub struct ElementHandleInnerHTMLResult {
285    #[serde(rename = "value")]
286    pub value: String,
287}
288
289/// Result of `ElementHandle.innerText` (Get inner text).
290#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
291pub struct ElementHandleInnerTextResult {
292    #[serde(rename = "value")]
293    pub value: String,
294}
295
296/// Result of `ElementHandle.inputValue` (Get input value).
297#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
298pub struct ElementHandleInputValueResult {
299    #[serde(rename = "value")]
300    pub value: String,
301}
302
303/// Result of `ElementHandle.isChecked` (Is checked).
304#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
305pub struct ElementHandleIsCheckedResult {
306    #[serde(rename = "value")]
307    pub value: bool,
308}
309
310/// Result of `ElementHandle.isDisabled` (Is disabled).
311#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
312pub struct ElementHandleIsDisabledResult {
313    #[serde(rename = "value")]
314    pub value: bool,
315}
316
317/// Result of `ElementHandle.isEditable` (Is editable).
318#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
319pub struct ElementHandleIsEditableResult {
320    #[serde(rename = "value")]
321    pub value: bool,
322}
323
324/// Result of `ElementHandle.isEnabled` (Is enabled).
325#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
326pub struct ElementHandleIsEnabledResult {
327    #[serde(rename = "value")]
328    pub value: bool,
329}
330
331/// Result of `ElementHandle.isHidden` (Is hidden).
332#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
333pub struct ElementHandleIsHiddenResult {
334    #[serde(rename = "value")]
335    pub value: bool,
336}
337
338/// Result of `ElementHandle.isVisible` (Is visible).
339#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
340pub struct ElementHandleIsVisibleResult {
341    #[serde(rename = "value")]
342    pub value: bool,
343}
344
345/// Result of `ElementHandle.ownerFrame` (Get owner frame).
346#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
347pub struct ElementHandleOwnerFrameResult {
348    #[serde(rename = "frame", default, skip_serializing_if = "Option::is_none")]
349    pub frame: Option<Ref<Frame>>,
350}
351
352/// Parameters of `ElementHandle.press` (Press "{key}").
353#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
354pub struct ElementHandlePressParams {
355    #[serde(rename = "key")]
356    pub key: String,
357    #[serde(rename = "delay", default, skip_serializing_if = "Option::is_none")]
358    pub delay: Option<f64>,
359    #[serde(rename = "noWaitAfter", default, skip_serializing_if = "Option::is_none")]
360    pub no_wait_after: Option<bool>,
361}
362
363/// Parameters of `ElementHandle.querySelector` (Query selector).
364#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
365pub struct ElementHandleQuerySelectorParams {
366    #[serde(rename = "selector")]
367    pub selector: String,
368    #[serde(rename = "strict", default, skip_serializing_if = "Option::is_none")]
369    pub strict: Option<bool>,
370}
371
372/// Result of `ElementHandle.querySelector` (Query selector).
373#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
374pub struct ElementHandleQuerySelectorResult {
375    #[serde(rename = "element", default, skip_serializing_if = "Option::is_none")]
376    pub element: Option<Ref<ElementHandle>>,
377}
378
379/// Parameters of `ElementHandle.querySelectorAll` (Query selector all).
380#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
381pub struct ElementHandleQuerySelectorAllParams {
382    #[serde(rename = "selector")]
383    pub selector: String,
384}
385
386/// Result of `ElementHandle.querySelectorAll` (Query selector all).
387#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
388pub struct ElementHandleQuerySelectorAllResult {
389    #[serde(rename = "elements")]
390    pub elements: Vec<Ref<ElementHandle>>,
391}
392
393#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
394pub enum ElementHandleScreenshotParamsType {
395    #[default]
396    #[serde(rename = "png")]
397    Png,
398    #[serde(rename = "jpeg")]
399    Jpeg,
400    #[serde(rename = "webp")]
401    Webp,
402}
403
404/// Parameters of `ElementHandle.screenshot` (Screenshot).
405#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
406pub struct ElementHandleScreenshotParams {
407    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
408    pub r#type: Option<ElementHandleScreenshotParamsType>,
409    #[serde(rename = "quality", default, skip_serializing_if = "Option::is_none")]
410    pub quality: Option<i64>,
411    /// Properties of the `CommonScreenshotOptions` mixin.
412    #[serde(flatten)]
413    pub common_screenshot_options: CommonScreenshotOptions,
414}
415
416/// Result of `ElementHandle.screenshot` (Screenshot).
417#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
418pub struct ElementHandleScreenshotResult {
419    #[serde(rename = "binary")]
420    pub binary: Binary,
421}
422
423#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
424pub struct ElementHandleSelectOptionParamsOptions {
425    #[serde(rename = "valueOrLabel", default, skip_serializing_if = "Option::is_none")]
426    pub value_or_label: Option<String>,
427    #[serde(rename = "value", default, skip_serializing_if = "Option::is_none")]
428    pub value: Option<String>,
429    #[serde(rename = "label", default, skip_serializing_if = "Option::is_none")]
430    pub label: Option<String>,
431    #[serde(rename = "index", default, skip_serializing_if = "Option::is_none")]
432    pub index: Option<i64>,
433}
434
435/// Parameters of `ElementHandle.selectOption` (Select option).
436#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
437pub struct ElementHandleSelectOptionParams {
438    #[serde(rename = "elements", default, skip_serializing_if = "Option::is_none")]
439    pub elements: Option<Vec<Ref<ElementHandle>>>,
440    #[serde(rename = "options", default, skip_serializing_if = "Option::is_none")]
441    pub options: Option<Vec<ElementHandleSelectOptionParamsOptions>>,
442    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
443    pub force: Option<bool>,
444}
445
446/// Result of `ElementHandle.selectOption` (Select option).
447#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
448pub struct ElementHandleSelectOptionResult {
449    #[serde(rename = "values")]
450    pub values: Vec<String>,
451}
452
453/// Parameters of `ElementHandle.selectText` (Select text).
454#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
455pub struct ElementHandleSelectTextParams {
456    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
457    pub force: Option<bool>,
458}
459
460#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
461pub struct ElementHandleSetInputFilesParamsPayloads {
462    #[serde(rename = "name")]
463    pub name: String,
464    #[serde(rename = "mimeType", default, skip_serializing_if = "Option::is_none")]
465    pub mime_type: Option<String>,
466    #[serde(rename = "buffer")]
467    pub buffer: Binary,
468}
469
470/// Parameters of `ElementHandle.setInputFiles` (Set input files).
471#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
472pub struct ElementHandleSetInputFilesParams {
473    #[serde(rename = "payloads", default, skip_serializing_if = "Option::is_none")]
474    pub payloads: Option<Vec<ElementHandleSetInputFilesParamsPayloads>>,
475    #[serde(rename = "localDirectory", default, skip_serializing_if = "Option::is_none")]
476    pub local_directory: Option<String>,
477    #[serde(rename = "directoryStream", default, skip_serializing_if = "Option::is_none")]
478    pub directory_stream: Option<Ref<WritableStream>>,
479    #[serde(rename = "localPaths", default, skip_serializing_if = "Option::is_none")]
480    pub local_paths: Option<Vec<String>>,
481    #[serde(rename = "streams", default, skip_serializing_if = "Option::is_none")]
482    pub streams: Option<Vec<Ref<WritableStream>>>,
483}
484
485#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
486pub enum ElementHandleTapParamsScroll {
487    #[default]
488    #[serde(rename = "auto")]
489    Auto,
490    #[serde(rename = "none")]
491    None,
492}
493
494#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
495pub enum ElementHandleTapParamsModifiers {
496    #[default]
497    #[serde(rename = "Alt")]
498    Alt,
499    #[serde(rename = "Control")]
500    Control,
501    #[serde(rename = "ControlOrMeta")]
502    ControlOrMeta,
503    #[serde(rename = "Meta")]
504    Meta,
505    #[serde(rename = "Shift")]
506    Shift,
507}
508
509/// Parameters of `ElementHandle.tap` (Tap).
510#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
511pub struct ElementHandleTapParams {
512    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
513    pub force: Option<bool>,
514    #[serde(rename = "scroll", default, skip_serializing_if = "Option::is_none")]
515    pub scroll: Option<ElementHandleTapParamsScroll>,
516    #[serde(rename = "modifiers", default, skip_serializing_if = "Option::is_none")]
517    pub modifiers: Option<Vec<ElementHandleTapParamsModifiers>>,
518    #[serde(rename = "position", default, skip_serializing_if = "Option::is_none")]
519    pub position: Option<Point>,
520    #[serde(rename = "trial", default, skip_serializing_if = "Option::is_none")]
521    pub trial: Option<bool>,
522}
523
524/// Result of `ElementHandle.textContent` (Get text content).
525#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
526pub struct ElementHandleTextContentResult {
527    #[serde(rename = "value", default, skip_serializing_if = "Option::is_none")]
528    pub value: Option<String>,
529}
530
531/// Parameters of `ElementHandle.type` (Type).
532#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
533pub struct ElementHandleTypeParams {
534    #[serde(rename = "text")]
535    pub text: String,
536    #[serde(rename = "delay", default, skip_serializing_if = "Option::is_none")]
537    pub delay: Option<f64>,
538}
539
540#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
541pub enum ElementHandleUncheckParamsScroll {
542    #[default]
543    #[serde(rename = "auto")]
544    Auto,
545    #[serde(rename = "none")]
546    None,
547}
548
549/// Parameters of `ElementHandle.uncheck` (Uncheck).
550#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
551pub struct ElementHandleUncheckParams {
552    #[serde(rename = "force", default, skip_serializing_if = "Option::is_none")]
553    pub force: Option<bool>,
554    #[serde(rename = "scroll", default, skip_serializing_if = "Option::is_none")]
555    pub scroll: Option<ElementHandleUncheckParamsScroll>,
556    #[serde(rename = "position", default, skip_serializing_if = "Option::is_none")]
557    pub position: Option<Point>,
558    #[serde(rename = "trial", default, skip_serializing_if = "Option::is_none")]
559    pub trial: Option<bool>,
560}
561
562#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
563pub enum ElementHandleWaitForElementStateParamsState {
564    #[default]
565    #[serde(rename = "visible")]
566    Visible,
567    #[serde(rename = "hidden")]
568    Hidden,
569    #[serde(rename = "stable")]
570    Stable,
571    #[serde(rename = "enabled")]
572    Enabled,
573    #[serde(rename = "disabled")]
574    Disabled,
575    #[serde(rename = "editable")]
576    Editable,
577}
578
579/// Parameters of `ElementHandle.waitForElementState` (Wait for state).
580#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
581pub struct ElementHandleWaitForElementStateParams {
582    #[serde(rename = "state")]
583    pub state: ElementHandleWaitForElementStateParamsState,
584}
585
586#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
587pub enum ElementHandleWaitForSelectorParamsState {
588    #[default]
589    #[serde(rename = "attached")]
590    Attached,
591    #[serde(rename = "detached")]
592    Detached,
593    #[serde(rename = "visible")]
594    Visible,
595    #[serde(rename = "hidden")]
596    Hidden,
597}
598
599/// Parameters of `ElementHandle.waitForSelector` (Wait for selector).
600#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
601pub struct ElementHandleWaitForSelectorParams {
602    #[serde(rename = "selector")]
603    pub selector: String,
604    #[serde(rename = "strict", default, skip_serializing_if = "Option::is_none")]
605    pub strict: Option<bool>,
606    #[serde(rename = "state", default, skip_serializing_if = "Option::is_none")]
607    pub state: Option<ElementHandleWaitForSelectorParamsState>,
608}
609
610/// Result of `ElementHandle.waitForSelector` (Wait for selector).
611#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
612pub struct ElementHandleWaitForSelectorResult {
613    #[serde(rename = "element", default, skip_serializing_if = "Option::is_none")]
614    pub element: Option<Ref<ElementHandle>>,
615}
616
617/// Events a `ElementHandle` channel can emit.
618#[derive(Debug, Clone, PartialEq)]
619pub enum ElementHandleEvent {
620    /// `JSHandle.previewUpdated`
621    PreviewUpdated(JSHandlePreviewUpdatedEventParams),
622    /// An event this binding does not know (a newer driver).
623    Unknown {
624        /// Event name.
625        method: String,
626        /// Raw event parameters.
627        params: serde_json::Value,
628    },
629}
630
631impl ProtocolEvent for ElementHandleEvent {
632    fn parse(method: &str, params: serde_json::Value) -> Result<Self, serde_json::Error> {
633        match method {
634            "previewUpdated" => Ok(Self::PreviewUpdated(serde_json::from_value(params)?)),
635            _ => Ok(Self::Unknown { method: method.to_string(), params }),
636        }
637    }
638}
639
640/// Channel for the `ElementHandle` interface (`handles.yml`).
641#[derive(Debug, Clone)]
642pub struct ElementHandle {
643    channel: Channel,
644}
645
646impl ChannelType for ElementHandle {
647    const INTERFACE: &'static str = "ElementHandle";
648    type Initializer = ElementHandleInitializer;
649    type Event = ElementHandleEvent;
650
651    fn accepts(interface: &str) -> bool {
652        matches!(interface, "ElementHandle")
653    }
654
655    fn from_channel(channel: Channel) -> Self {
656        Self { channel }
657    }
658
659    fn channel(&self) -> &Channel {
660        &self.channel
661    }
662}
663
664impl ElementHandle {
665    /// `JSHandle.dispose` (internal).
666    pub async fn dispose(&self) -> Result<(), ProtocolError> {
667        self.channel.send_no_result("dispose", &serde_json::json!({})).await
668    }
669
670    /// `JSHandle.evaluateExpression` ("Evaluate").
671    pub async fn evaluate_expression(&self, params: JSHandleEvaluateExpressionParams) -> Result<JSHandleEvaluateExpressionResult, ProtocolError> {
672        self.channel.send("evaluateExpression", &params).await
673    }
674
675    /// `JSHandle.evaluateExpressionHandle` ("Evaluate").
676    pub async fn evaluate_expression_handle(&self, params: JSHandleEvaluateExpressionHandleParams) -> Result<JSHandleEvaluateExpressionHandleResult, ProtocolError> {
677        self.channel.send("evaluateExpressionHandle", &params).await
678    }
679
680    /// `JSHandle.getPropertyList` ("Get property list").
681    pub async fn get_property_list(&self) -> Result<JSHandleGetPropertyListResult, ProtocolError> {
682        self.channel.send("getPropertyList", &serde_json::json!({})).await
683    }
684
685    /// `JSHandle.getProperty` ("Get JS property").
686    pub async fn get_property(&self, params: JSHandleGetPropertyParams) -> Result<JSHandleGetPropertyResult, ProtocolError> {
687        self.channel.send("getProperty", &params).await
688    }
689
690    /// `JSHandle.jsonValue` ("Get JSON value").
691    pub async fn json_value(&self) -> Result<JSHandleJsonValueResult, ProtocolError> {
692        self.channel.send("jsonValue", &serde_json::json!({})).await
693    }
694
695    /// `ElementHandle.evalOnSelector` ("Evaluate").
696    pub async fn eval_on_selector(&self, params: ElementHandleEvalOnSelectorParams) -> Result<ElementHandleEvalOnSelectorResult, ProtocolError> {
697        self.channel.send("evalOnSelector", &params).await
698    }
699
700    /// `ElementHandle.evalOnSelectorAll` ("Evaluate").
701    pub async fn eval_on_selector_all(&self, params: ElementHandleEvalOnSelectorAllParams) -> Result<ElementHandleEvalOnSelectorAllResult, ProtocolError> {
702        self.channel.send("evalOnSelectorAll", &params).await
703    }
704
705    /// `ElementHandle.boundingBox` ("Get bounding box").
706    pub async fn bounding_box(&self) -> Result<ElementHandleBoundingBoxResult, ProtocolError> {
707        self.channel.send("boundingBox", &serde_json::json!({})).await
708    }
709
710    /// `ElementHandle.check` ("Check").
711    pub async fn check(&self, params: ElementHandleCheckParams) -> Result<(), ProtocolError> {
712        self.channel.send_no_result("check", &params).await
713    }
714
715    /// `ElementHandle.click` ("Click").
716    pub async fn click(&self, params: ElementHandleClickParams) -> Result<(), ProtocolError> {
717        self.channel.send_no_result("click", &params).await
718    }
719
720    /// `ElementHandle.contentFrame` ("Get content frame").
721    pub async fn content_frame(&self) -> Result<ElementHandleContentFrameResult, ProtocolError> {
722        self.channel.send("contentFrame", &serde_json::json!({})).await
723    }
724
725    /// `ElementHandle.dblclick` ("Double click").
726    pub async fn dblclick(&self, params: ElementHandleDblclickParams) -> Result<(), ProtocolError> {
727        self.channel.send_no_result("dblclick", &params).await
728    }
729
730    /// `ElementHandle.dispatchEvent` ("Dispatch event").
731    pub async fn dispatch_event(&self, params: ElementHandleDispatchEventParams) -> Result<(), ProtocolError> {
732        self.channel.send_no_result("dispatchEvent", &params).await
733    }
734
735    /// `ElementHandle.fill` ("Fill "{value}"").
736    pub async fn fill(&self, params: ElementHandleFillParams) -> Result<(), ProtocolError> {
737        self.channel.send_no_result("fill", &params).await
738    }
739
740    /// `ElementHandle.focus` ("Focus").
741    pub async fn focus(&self) -> Result<(), ProtocolError> {
742        self.channel.send_no_result("focus", &serde_json::json!({})).await
743    }
744
745    /// `ElementHandle.getAttribute` ("Get attribute").
746    pub async fn get_attribute(&self, params: ElementHandleGetAttributeParams) -> Result<ElementHandleGetAttributeResult, ProtocolError> {
747        self.channel.send("getAttribute", &params).await
748    }
749
750    /// `ElementHandle.hover` ("Hover").
751    pub async fn hover(&self, params: ElementHandleHoverParams) -> Result<(), ProtocolError> {
752        self.channel.send_no_result("hover", &params).await
753    }
754
755    /// `ElementHandle.innerHTML` ("Get HTML").
756    pub async fn inner_html(&self) -> Result<ElementHandleInnerHTMLResult, ProtocolError> {
757        self.channel.send("innerHTML", &serde_json::json!({})).await
758    }
759
760    /// `ElementHandle.innerText` ("Get inner text").
761    pub async fn inner_text(&self) -> Result<ElementHandleInnerTextResult, ProtocolError> {
762        self.channel.send("innerText", &serde_json::json!({})).await
763    }
764
765    /// `ElementHandle.inputValue` ("Get input value").
766    pub async fn input_value(&self) -> Result<ElementHandleInputValueResult, ProtocolError> {
767        self.channel.send("inputValue", &serde_json::json!({})).await
768    }
769
770    /// `ElementHandle.isChecked` ("Is checked").
771    pub async fn is_checked(&self) -> Result<ElementHandleIsCheckedResult, ProtocolError> {
772        self.channel.send("isChecked", &serde_json::json!({})).await
773    }
774
775    /// `ElementHandle.isDisabled` ("Is disabled").
776    pub async fn is_disabled(&self) -> Result<ElementHandleIsDisabledResult, ProtocolError> {
777        self.channel.send("isDisabled", &serde_json::json!({})).await
778    }
779
780    /// `ElementHandle.isEditable` ("Is editable").
781    pub async fn is_editable(&self) -> Result<ElementHandleIsEditableResult, ProtocolError> {
782        self.channel.send("isEditable", &serde_json::json!({})).await
783    }
784
785    /// `ElementHandle.isEnabled` ("Is enabled").
786    pub async fn is_enabled(&self) -> Result<ElementHandleIsEnabledResult, ProtocolError> {
787        self.channel.send("isEnabled", &serde_json::json!({})).await
788    }
789
790    /// `ElementHandle.isHidden` ("Is hidden").
791    pub async fn is_hidden(&self) -> Result<ElementHandleIsHiddenResult, ProtocolError> {
792        self.channel.send("isHidden", &serde_json::json!({})).await
793    }
794
795    /// `ElementHandle.isVisible` ("Is visible").
796    pub async fn is_visible(&self) -> Result<ElementHandleIsVisibleResult, ProtocolError> {
797        self.channel.send("isVisible", &serde_json::json!({})).await
798    }
799
800    /// `ElementHandle.ownerFrame` ("Get owner frame").
801    pub async fn owner_frame(&self) -> Result<ElementHandleOwnerFrameResult, ProtocolError> {
802        self.channel.send("ownerFrame", &serde_json::json!({})).await
803    }
804
805    /// `ElementHandle.press` ("Press "{key}"").
806    pub async fn press(&self, params: ElementHandlePressParams) -> Result<(), ProtocolError> {
807        self.channel.send_no_result("press", &params).await
808    }
809
810    /// `ElementHandle.querySelector` ("Query selector").
811    pub async fn query_selector(&self, params: ElementHandleQuerySelectorParams) -> Result<ElementHandleQuerySelectorResult, ProtocolError> {
812        self.channel.send("querySelector", &params).await
813    }
814
815    /// `ElementHandle.querySelectorAll` ("Query selector all").
816    pub async fn query_selector_all(&self, params: ElementHandleQuerySelectorAllParams) -> Result<ElementHandleQuerySelectorAllResult, ProtocolError> {
817        self.channel.send("querySelectorAll", &params).await
818    }
819
820    /// `ElementHandle.screenshot` ("Screenshot").
821    pub async fn screenshot(&self, params: ElementHandleScreenshotParams) -> Result<ElementHandleScreenshotResult, ProtocolError> {
822        self.channel.send("screenshot", &params).await
823    }
824
825    /// `ElementHandle.scrollIntoViewIfNeeded` ("Scroll into view").
826    pub async fn scroll_into_view_if_needed(&self) -> Result<(), ProtocolError> {
827        self.channel.send_no_result("scrollIntoViewIfNeeded", &serde_json::json!({})).await
828    }
829
830    /// `ElementHandle.selectOption` ("Select option").
831    pub async fn select_option(&self, params: ElementHandleSelectOptionParams) -> Result<ElementHandleSelectOptionResult, ProtocolError> {
832        self.channel.send("selectOption", &params).await
833    }
834
835    /// `ElementHandle.selectText` ("Select text").
836    pub async fn select_text(&self, params: ElementHandleSelectTextParams) -> Result<(), ProtocolError> {
837        self.channel.send_no_result("selectText", &params).await
838    }
839
840    /// `ElementHandle.setInputFiles` ("Set input files").
841    pub async fn set_input_files(&self, params: ElementHandleSetInputFilesParams) -> Result<(), ProtocolError> {
842        self.channel.send_no_result("setInputFiles", &params).await
843    }
844
845    /// `ElementHandle.tap` ("Tap").
846    pub async fn tap(&self, params: ElementHandleTapParams) -> Result<(), ProtocolError> {
847        self.channel.send_no_result("tap", &params).await
848    }
849
850    /// `ElementHandle.textContent` ("Get text content").
851    pub async fn text_content(&self) -> Result<ElementHandleTextContentResult, ProtocolError> {
852        self.channel.send("textContent", &serde_json::json!({})).await
853    }
854
855    /// `ElementHandle.type` ("Type").
856    pub async fn r#type(&self, params: ElementHandleTypeParams) -> Result<(), ProtocolError> {
857        self.channel.send_no_result("type", &params).await
858    }
859
860    /// `ElementHandle.uncheck` ("Uncheck").
861    pub async fn uncheck(&self, params: ElementHandleUncheckParams) -> Result<(), ProtocolError> {
862        self.channel.send_no_result("uncheck", &params).await
863    }
864
865    /// `ElementHandle.waitForElementState` ("Wait for state").
866    pub async fn wait_for_element_state(&self, params: ElementHandleWaitForElementStateParams) -> Result<(), ProtocolError> {
867        self.channel.send_no_result("waitForElementState", &params).await
868    }
869
870    /// `ElementHandle.waitForSelector` ("Wait for selector").
871    pub async fn wait_for_selector(&self, params: ElementHandleWaitForSelectorParams) -> Result<ElementHandleWaitForSelectorResult, ProtocolError> {
872        self.channel.send("waitForSelector", &params).await
873    }
874}