Skip to content

Commit

Permalink
Add locator.Clear to mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur22 committed Jan 4, 2024
1 parent 7829e4d commit 7f4a038
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions browser/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions browser/mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7f4a038

Please sign in to comment.