Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

271
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda