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

Commit

Permalink
Async Frame.queryAll
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Jun 5, 2024
1 parent 4761214 commit 1a0a640
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions browser/frame_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,24 +284,26 @@ func mapFrame(vu moduleVU, f *common.Frame) mapping { //nolint:gocognit,cyclop
// We do not want to map nil elementHandles since the expectation is a
// null result in the test script for this case.
if eh == nil {
return nil, nil //nolint:nilnil
return nil, nil
}
ehm := mapElementHandle(vu, eh)

return ehm, nil
})
}
maps["$$"] = func(selector string) ([]mapping, error) {
ehs, err := f.QueryAll(selector)
if err != nil {
return nil, err //nolint:wrapcheck
}
var mehs []mapping
for _, eh := range ehs {
ehm := mapElementHandle(vu, eh)
mehs = append(mehs, ehm)
}
return mehs, nil
maps["$$"] = func(selector string) *goja.Promise {
return k6ext.Promise(vu.Context(), func() (any, error) {
ehs, err := f.QueryAll(selector)
if err != nil {
return nil, err //nolint:wrapcheck
}
var mehs []mapping
for _, eh := range ehs {
ehm := mapElementHandle(vu, eh)
mehs = append(mehs, ehm)
}
return mehs, nil
})
}

return maps
Expand Down

0 comments on commit 1a0a640

Please # to comment.