0
votes

I want to select an option via playwright, but I cannot select an option. What is wrong?

MUI

          <Select
            data-testid="color"
          >
            <MenuItem value="red">
              red
            </MenuItem>
            <MenuItem value="green">
              green
            </MenuItem>

          </Select>

test

await page.selectOption("data-testid=color", "red)
1
how about await page.selectOption("[data-testid=color]", "red")hardkoded
@hardkoded I tried, but it also does not workvuvu

1 Answers

1
votes

There might be some whitespaces if what you copies is accurate. I'd try to select by value:

await page.selectOption('[data-testid=color]', { value: 'red' });