diff --git a/common/element_handle.go b/common/element_handle.go index b8a6c276d..d8feb5601 100644 --- a/common/element_handle.go +++ b/common/element_handle.go @@ -589,10 +589,6 @@ func (h *ElementHandle) selectText(apiCtx context.Context) error { return nil } -func (h *ElementHandle) tap(apiCtx context.Context, p *Position) error { - return h.frame.page.Touchscreen.tap(p.X, p.Y) -} - func (h *ElementHandle) textContent(apiCtx context.Context) (any, error) { js := ` (element) => { @@ -1312,6 +1308,10 @@ func (h *ElementHandle) Tap(opts goja.Value) { applySlowMo(h.ctx) } +func (h *ElementHandle) tap(apiCtx context.Context, p *Position) error { + return h.frame.page.Touchscreen.tap(p.X, p.Y) +} + func (h *ElementHandle) TextContent() string { fn := func(apiCtx context.Context, handle *ElementHandle) (any, error) { return handle.textContent(apiCtx) diff --git a/common/frame.go b/common/frame.go index 38b159e08..bd580f03a 100644 --- a/common/frame.go +++ b/common/frame.go @@ -1565,16 +1565,13 @@ func (f *Frame) Tap(selector string, opts goja.Value) error { return nil } -func (f *Frame) setInputFiles(selector string, files *Files, opts *FrameSetInputFilesOptions) error { - setInputFiles := func(apiCtx context.Context, handle *ElementHandle) (any, error) { - return nil, handle.setInputFiles(apiCtx, files.Payload) +func (f *Frame) tap(selector string, opts *FrameTapOptions) error { + tap := func(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) { + return nil, handle.tap(apiCtx, p) } - act := f.newAction( - selector, DOMElementStateAttached, opts.Strict, - setInputFiles, []string{}, - opts.Force, opts.NoWaitAfter, opts.Timeout, + act := f.newPointerAction( + selector, DOMElementStateAttached, opts.Strict, tap, &opts.ElementHandleBasePointerOptions, ) - if _, err := call(f.ctx, act, opts.Timeout); err != nil { return errorFromDOMError(err) } @@ -1582,13 +1579,16 @@ func (f *Frame) setInputFiles(selector string, files *Files, opts *FrameSetInput return nil } -func (f *Frame) tap(selector string, opts *FrameTapOptions) error { - tap := func(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) { - return nil, handle.tap(apiCtx, p) +func (f *Frame) setInputFiles(selector string, files *Files, opts *FrameSetInputFilesOptions) error { + setInputFiles := func(apiCtx context.Context, handle *ElementHandle) (any, error) { + return nil, handle.setInputFiles(apiCtx, files.Payload) } - act := f.newPointerAction( - selector, DOMElementStateAttached, opts.Strict, tap, &opts.ElementHandleBasePointerOptions, + act := f.newAction( + selector, DOMElementStateAttached, opts.Strict, + setInputFiles, []string{}, + opts.Force, opts.NoWaitAfter, opts.Timeout, ) + if _, err := call(f.ctx, act, opts.Timeout); err != nil { return errorFromDOMError(err) }