/
autofill.go
113 lines (96 loc) · 3.49 KB
/
autofill.go
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
// Package autofill provides the Chrome DevTools Protocol
// commands, types, and events for the Autofill domain.
//
// Defines commands and events for Autofill.
//
// Generated by the cdproto-gen command.
package autofill
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"context"
"github.com/chromedp/cdproto/cdp"
)
// TriggerParams trigger autofill on a form identified by the fieldId. If the
// field and related form cannot be autofilled, returns an error.
type TriggerParams struct {
FieldID cdp.BackendNodeID `json:"fieldId"` // Identifies a field that serves as an anchor for autofill.
FrameID cdp.FrameID `json:"frameId,omitempty"` // Identifies the frame that field belongs to.
Card *CreditCard `json:"card"` // Credit card information to fill out the form. Credit card data is not saved.
}
// Trigger trigger autofill on a form identified by the fieldId. If the field
// and related form cannot be autofilled, returns an error.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Autofill#method-trigger
//
// parameters:
//
// fieldID - Identifies a field that serves as an anchor for autofill.
// card - Credit card information to fill out the form. Credit card data is not saved.
func Trigger(fieldID cdp.BackendNodeID, card *CreditCard) *TriggerParams {
return &TriggerParams{
FieldID: fieldID,
Card: card,
}
}
// WithFrameID identifies the frame that field belongs to.
func (p TriggerParams) WithFrameID(frameID cdp.FrameID) *TriggerParams {
p.FrameID = frameID
return &p
}
// Do executes Autofill.trigger against the provided context.
func (p *TriggerParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandTrigger, p, nil)
}
// SetAddressesParams set addresses so that developers can verify their forms
// implementation.
type SetAddressesParams struct {
Addresses []*Address `json:"addresses"`
}
// SetAddresses set addresses so that developers can verify their forms
// implementation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Autofill#method-setAddresses
//
// parameters:
//
// addresses
func SetAddresses(addresses []*Address) *SetAddressesParams {
return &SetAddressesParams{
Addresses: addresses,
}
}
// Do executes Autofill.setAddresses against the provided context.
func (p *SetAddressesParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetAddresses, p, nil)
}
// DisableParams disables autofill domain notifications.
type DisableParams struct{}
// Disable disables autofill domain notifications.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Autofill#method-disable
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Autofill.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
}
// EnableParams enables autofill domain notifications.
type EnableParams struct{}
// Enable enables autofill domain notifications.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Autofill#method-enable
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Autofill.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandEnable, nil, nil)
}
// Command names.
const (
CommandTrigger = "Autofill.trigger"
CommandSetAddresses = "Autofill.setAddresses"
CommandDisable = "Autofill.disable"
CommandEnable = "Autofill.enable"
)