Skip to content

Commit

Permalink
browser: Fix ElemenHandle.SelectOption sobek
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Feb 24, 2025
1 parent 2c5f7b2 commit 07d1906
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@ func mapElementHandle(vu moduleVU, eh *common.ElementHandle) mapping { //nolint:
if err != nil {
return nil, fmt.Errorf("parsing select options values: %w", err)
}
popts := common.NewElementHandleBaseOptions(eh.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing selectOption options: %w", err)
}
return k6ext.Promise(vu.Context(), func() (any, error) {
return eh.SelectOption(convValues, opts) //nolint:wrapcheck
return eh.SelectOption(convValues, popts) //nolint:wrapcheck
}), nil
},
"selectText": func(opts sobek.Value) (*sobek.Promise, error) {
Expand Down
11 changes: 3 additions & 8 deletions internal/js/modules/k6/browser/common/element_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -1306,19 +1306,14 @@ func (h *ElementHandle) ScrollIntoViewIfNeeded(opts *ElementHandleBaseOptions) e
}

// SelectOption selects the options matching the given values.
func (h *ElementHandle) SelectOption(values []any, opts sobek.Value) ([]string, error) {
aopts := NewElementHandleBaseOptions(h.DefaultTimeout())
if err := aopts.Parse(h.ctx, opts); err != nil {
return nil, fmt.Errorf("parsing selectOption options: %w", err)
}

func (h *ElementHandle) SelectOption(values []any, opts *ElementHandleBaseOptions) ([]string, error) {
selectOption := func(apiCtx context.Context, handle *ElementHandle) (any, error) {
return handle.selectOption(apiCtx, values)
}
selectOptionAction := h.newAction(
[]string{}, selectOption, aopts.Force, aopts.NoWaitAfter, aopts.Timeout,
[]string{}, selectOption, opts.Force, opts.NoWaitAfter, opts.Timeout,
)
selectedOptions, err := call(h.ctx, selectOptionAction, aopts.Timeout)
selectedOptions, err := call(h.ctx, selectOptionAction, opts.Timeout)
if err != nil {
return nil, fmt.Errorf("selecting options: %w", err)
}
Expand Down

0 comments on commit 07d1906

Please sign in to comment.