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

Form select options without value attribute #4071

Open
jbq opened this issue Nov 16, 2024 · 0 comments
Open

Form select options without value attribute #4071

jbq opened this issue Nov 16, 2024 · 0 comments
Assignees

Comments

@jbq
Copy link

jbq commented Nov 16, 2024

Brief summary

Consider the following form:

            <select size="2" name="civility" tabIndex="-1" title="">
              <option></option>
              <option value="madame">Madame</option>
              <option value="monsieur">Monsieur</option>
            </select>

The following test scenario fails:

    const civilitySelect = await page.locator('//select[@name="civility"]')
    await civilitySelect.selectOption(["monsieur"])

k6 version

k6 v0.55.0 (go1.23.3, darwin/amd64)

OS

macOS 15.0.1

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Full script to reproduce:

export default async function () {
  const context = await browser.newContext();
  const page = await context.newPage();

  const url = `https://k6-bugs.vercel.app/`
  console.log("Using URL", url)

  try {
    await page.goto(url);
    const civilitySelect = await page.locator('//select[@name="civility"]')
    await civilitySelect.selectOption(["monsieur"])
  } finally {
    await page.close();
  }
}

Expected behaviour

k6 should be able to parse the option without a value attribute.

: The HTML Option element - HTML: HyperText Markup Language | MDN

The content of this attribute represents the value to be submitted with the form, should this option be selected. If this attribute is omitted, the value is taken from the text content of the option element.

Actual behaviour

Error details:

ERRO[0002] Uncaught (in promise) selecting option on "//select[@name=\"civility\"]": TypeError: Cannot read properties of null (reading 'slice')
    at InjectedScript.selectOptions (__xk6_browser_evaluation_script__:724:52)
    at __xk6_browser_evaluation_script__:3:20  executor=shared-iterations scenario=ui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants