diff --git a/browser/mapping.go b/browser/mapping.go index bd9d8ced5..2482009d9 100644 --- a/browser/mapping.go +++ b/browser/mapping.go @@ -41,6 +41,16 @@ func mapBrowserToGoja(vu moduleVU) *goja.Object { // mapLocator API to the JS module. func mapLocator(vu moduleVU, lo *common.Locator) mapping { return mapping{ + "clear": func(opts goja.Value) error { + ctx := vu.Context() + + copts := common.NewFrameFillOptions(lo.Timeout()) + if err := copts.Parse(ctx, opts); err != nil { + return fmt.Errorf("parsing clear options: %w", err) + } + + return lo.Clear(copts) //nolint:wrapcheck + }, "click": func(opts goja.Value) *goja.Promise { return k6ext.Promise(vu.Context(), func() (any, error) { err := lo.Click(opts) diff --git a/browser/mapping_test.go b/browser/mapping_test.go index e7568455e..a89c4bfaf 100644 --- a/browser/mapping_test.go +++ b/browser/mapping_test.go @@ -511,6 +511,7 @@ type responseAPI interface { // locatorAPI represents a way to find element(s) on a page at any moment. type locatorAPI interface { + Clear(opts *common.FrameFillOptions) error Click(opts goja.Value) error Dblclick(opts goja.Value) Check(opts goja.Value)