Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

273
Visualizações
playwright locator.selectOption using an array of values

I read the playwright documentation concerning locator.selectOption, however it seems a bit incomplete as I still have the following question, which of label or value does the selectOption use when it receives an array as its parameter?

more info:

The page gives the following examples:

// single selection matching the value
element.selectOption('blue');

// single selection matching the label
element.selectOption({ label: 'Blue' });

// multiple selection
element.selectOption(['red', 'green', 'blue']);

But, suppose my select is:

<select id="state" name="state">
  <option value="AL">Alabama</option>
  <option value="AK">Alaska</option>
  <option value="AZ">Arizona</option>
  <option value="AR">Arkansas</option>
  ...
</select>

Would the following work? page.locator('#state').selectOption([ "Alabama", "Arkansas" ]);

Or would I need to do: page.locator('#state').selectOption([ "AL", "AR" ]);

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The docs says String values are equivalent to {value:'string'}, So it would be the equivalent to page.locator('#state').selectOption([ "AL", "AR" ]);

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda