Skip to content

Commit

Permalink
Degojaify Locator.Tap
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Apr 17, 2024
1 parent e09c4a8 commit f0e3910
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 7 additions & 1 deletion browser/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ func mapLocator(vu moduleVU, lo *common.Locator) mapping {
"press": lo.Press,
"type": lo.Type,
"hover": lo.Hover,
"tap": lo.Tap,
"tap": func(opts goja.Value) error {
copts := common.NewFrameTapOptions(lo.DefaultTimeout())
if err := copts.Parse(vu.Context(), opts); err != nil {
return fmt.Errorf("parsing tap options: %w", err)
}
return lo.Tap(copts) //nolint:wrapcheck
},
"dispatchEvent": func(typ string, eventInit, opts goja.Value) error {
popts := common.NewFrameDispatchEventOptions(lo.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
Expand Down
10 changes: 3 additions & 7 deletions common/locator.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,15 +561,11 @@ func (l *Locator) hover(opts *FrameHoverOptions) error {
}

// Tap the element found that matches the locator's selector with strict mode on.
func (l *Locator) Tap(opts goja.Value) error {
func (l *Locator) Tap(opts *FrameTapOptions) error {
l.log.Debugf("Locator:Tap", "fid:%s furl:%q sel:%q opts:%+v", l.frame.ID(), l.frame.URL(), l.selector, opts)

copts := NewFrameTapOptions(l.frame.defaultTimeout())
if err := copts.Parse(l.ctx, opts); err != nil {
return fmt.Errorf("parsing tap options: %w", err)
}
copts.Strict = true
if err := l.frame.tap(l.selector, copts); err != nil {
opts.Strict = true
if err := l.frame.tap(l.selector, opts); err != nil {
return fmt.Errorf("tapping on %q: %w", l.selector, err)
}

Expand Down

0 comments on commit f0e3910

Please sign in to comment.