Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Move Page|EHandle.Tap and tap closer
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Apr 18, 2024
1 parent 7132d34 commit 9bd80f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions common/element_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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)
Expand Down
26 changes: 13 additions & 13 deletions common/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -1565,30 +1565,30 @@ 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)
}

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)
}
Expand Down

0 comments on commit 9bd80f9

Please sign in to comment.