Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

302
Views
Dramaturgo: ¿Cómo buscar un elemento que tiene una etiqueta vacía específica en el árbol de elementos?

¿Cómo buscar un elemento que tiene una etiqueta vacía específica en el árbol de elementos en las pruebas de Playwright (usando su corredor de prueba)?

He probado un filtro de texto vacío (obviamente no es la mejor idea)

 // variant 1 page.locator(`[aria-label="label name"].has(span:text-is(""))`); // variant 2 page.locator(`[aria-label="label name"].has(div[role="button"] span[text=""])`);

pero obtuve un error

 locator.textContent: Unexpected token "" while parsing selector "[aria-label="label name"]"

La única solución que me funciona es verificar cada contenido de texto usando JS, por ejemplo:

 const locator = page.locator('div[role="button"] >> span'); const elementsCount = await locator.count(); for(let i = 0; i < elementsCount; i++) { const spanTextContent = await locator.nth(i)?.textContent(); return spanTextContent === '' ? locator.nth(i) : null; }

Otro ejemplo que da Unexpected token "" while parsing selector :

 locator = page.locator(`body:has(div[class="L3eUgb"] >> a >> text="About")`); console.log(`locator.count(): ${await locator.count()}`);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Parece que estás mezclando un poco mal los selectores de CSS y las pseudoclases personalizadas de Playwright.

Esto debería funcionar para usted:

 page.locator('div[role="button"] >> span >> text=""')

ACTUALIZAR:

 page.locator(`body:has(div[class="L3eUgb"]) >> a >> text="About"`)

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!