Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to selectOption using object #1415

Open
pyrophos opened this issue Sep 4, 2024 · 0 comments
Open

Unable to selectOption using object #1415

pyrophos opened this issue Sep 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@pyrophos
Copy link

pyrophos commented Sep 4, 2024

Brief summary

Unable to selectOption using object as described here: https://grafana.com/docs/k6/latest/javascript-api/k6-browser/locator/selectoption/

If the select has the multiple attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. Object can be made up of keys with value, label or index.

Supported by Playwright: https://playwright.dev/docs/input#select-options

Example: options.selectOption({label:'Five'})

xk6-browser version

128.0.6613.115

OS

Windows 11 Enterprise, 10.0.22631 Build 22631

Chrome version

128.0.6613.115

Docker version and image (if applicable)

No response

Steps to reproduce the problem

import { browser } from 'k6/browser';

export const options = {
  scenarios: {
    browser: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
};

export default async function () {
  const page = await browser.newPage();
  await page.goto('https://test.k6.io/browser.php');
  const options = page.locator('#numbers-options');
  await options.selectOption({label:'Five'});
}

Expected behaviour

Selecting "Five" from the numbers-options selection box

Actual behaviour

panic: reflect: call of reflect.Value.Index on map Value
running (00m02.9s), 1/1 VUs, 0 complete and 0 interrupted iterations
goroutine 259 [running]:-------------------------] 1 VUs  00m02.9s/10m0s  0/1 shared iters
reflect.Value.Index({0x239ee60?, 0xc000567230?, 0xc000048460?}, 0xeea9fd?)
        reflect/value.go:1447 +0x154
github.com/grafana/xk6-browser/common.(*ElementHandle).selectOption.func1({0x29dafd8, 0xc000464ff0})
        github.com/grafana/[email protected]/common/element_handle.go:495 +0x828
github.com/grafana/xk6-browser/common.(*ElementHandle).selectOption(0xc000518640, {0x29c67f8, 0xc00046e2a0}, {0x29dafd8?, 0xc000464ff0?})
        github.com/grafana/[email protected]/common/element_handle.go:551 +0x63
github.com/grafana/xk6-browser/common.(*Frame).selectOption.func1({0x29c67f8?, 0xc00046e2a0?}, 0xc00046e2a0?)
        github.com/grafana/[email protected]/common/frame.go:1502 +0x34
github.com/grafana/xk6-browser/common.(*ElementHandle).newAction.func1({0x29c67f8, 0xc00046e2a0})
        github.com/grafana/[email protected]/common/element_handle.go:1545 +0x1b3
github.com/grafana/xk6-browser/common.(*ElementHandle).newAction.func2({0x29c67f8?, 0xc00046e2a0?}, 0xc0004e6720, 0xc0004e6780)
        github.com/grafana/[email protected]/common/element_handle.go:1560 +0x3b
github.com/grafana/xk6-browser/common.(*Frame).selectOption.(*Frame).newAction.func2({0x29c67f8, 0xc00046e2a0}, 0xc0004e6720, 0xc0004e6780)
        github.com/grafana/[email protected]/common/frame.go:2117 +0x178
created by github.com/grafana/xk6-browser/common.call in goroutine 258
        github.com/grafana/[email protected]/common/helpers.go:103 +0x14c
@pyrophos pyrophos added the bug Something isn't working label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant