-
-
Notifications
You must be signed in to change notification settings - Fork 164
/
file_chooser.go
44 lines (37 loc) · 1.05 KB
/
file_chooser.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
package playwright
type fileChooserImpl struct {
page Page
elementHandle ElementHandle
isMultiple bool
}
func (f *fileChooserImpl) Page() Page {
return f.page
}
func (f *fileChooserImpl) Element() ElementHandle {
return f.elementHandle
}
func (f *fileChooserImpl) IsMultiple() bool {
return f.isMultiple
}
// InputFile represents the input file for:
// - FileChooser.SetFiles()
// - ElementHandle.SetInputFiles()
// - Page.SetInputFiles()
type InputFile struct {
Name string `json:"name"`
MimeType string `json:"mimeType,omitempty"`
Buffer []byte `json:"buffer"`
}
func (f *fileChooserImpl) SetFiles(files interface{}, options ...FileChooserSetFilesOptions) error {
if len(options) == 1 {
return f.elementHandle.SetInputFiles(files, ElementHandleSetInputFilesOptions(options[0]))
}
return f.elementHandle.SetInputFiles(files)
}
func newFileChooser(page Page, elementHandle ElementHandle, isMultiple bool) *fileChooserImpl {
return &fileChooserImpl{
page: page,
elementHandle: elementHandle,
isMultiple: isMultiple,
}
}