Skip to content

Commit

Permalink
Fix page evaluates for missing arg
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Nov 26, 2024
1 parent e465fc2 commit 553f3a3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions browser/page_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,25 @@ func mapPage(vu moduleVU, p *common.Page) mapping { //nolint:gocognit,cyclop
return nil, p.EmulateVisionDeficiency(typ) //nolint:wrapcheck
})
},
"evaluate": func(pageFunction sobek.Value, gargs ...sobek.Value) *sobek.Promise {
"evaluate": func(pageFunc sobek.Value, gargs ...sobek.Value) (*sobek.Promise, error) {
if sobekEmptyString(pageFunc) {
return nil, fmt.Errorf("evaluate requires a page function")
}
return k6ext.Promise(vu.Context(), func() (any, error) {
return p.Evaluate(pageFunction.String(), exportArgs(gargs)...) //nolint:wrapcheck
})
return p.Evaluate(pageFunc.String(), exportArgs(gargs)...)
}), nil
},
"evaluateHandle": func(pageFunc sobek.Value, gargs ...sobek.Value) *sobek.Promise {
"evaluateHandle": func(pageFunc sobek.Value, gargs ...sobek.Value) (*sobek.Promise, error) {
if sobekEmptyString(pageFunc) {
return nil, fmt.Errorf("evaluateHandle requires a page function")
}
return k6ext.Promise(vu.Context(), func() (any, error) {
jsh, err := p.EvaluateHandle(pageFunc.String(), exportArgs(gargs)...)
if err != nil {
return nil, err //nolint:wrapcheck
}
return mapJSHandle(vu, jsh), nil
})
}), nil
},
"fill": func(selector string, value string, opts sobek.Value) *sobek.Promise {
return k6ext.Promise(vu.Context(), func() (any, error) {
Expand Down

0 comments on commit 553f3a3

Please sign in to comment.