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

88
Views
Obtenga cómo mant <li> bajo <ul> usando Titiritero

Tengo el siguiente código:

 it('7.1.8 - In Platform admin could review all ongoing and published notifications', async () => { const allNotificationList = await page.waitForXPath( '//header[contains(@class,"ant-layout-header")]//ul[contains(@class,"Notifications_banner-notifications")]', ); expect(allNotificationList.length).not.toBe(0); });

allNotificationList obtiene la etiqueta ul y quiero verificar cuántas etiquetas li hay debajo de la etiqueta ul seleccionada.

¿Alguien sabe cómo lograr esto usando Puppetter?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Puede usar page.$x (o someElement.$x ) para devolver un ElementHandle[] ( page.waitForXPath devuelve un solo ElementHandle ):

 const allNotificationList = await page.$x( '//header[contains(@class,"ant-layout-header")]//ul[contains(@class,"Notifications_banner-notifications")]', ); expect(allNotificationList.length).not.toBe(0);

Sin embargo, no creo que en realidad espere los elementos, por lo que es posible que desee agregar la siguiente línea primero:

 await page.waitForXPath( '//header[contains(@class,"ant-layout-header")]//ul[contains(@class,"Notifications_banner-notifications")]', );
about 4 years ago · Juan Pablo Isaza Report

0

No tengo una solución para esto con Xpath, pero si está abierto a dar forma al selector de Xpath a CSS, lo siguiente hará lo que necesita. Usando childElementCount .

 const selector = 'header.ant-layout-header * ul.Notifications_banner-notifications' const childCount = await page.$eval(selector, el => el.childElementCount) expect(childCount).toBeGreaterThan(0)
about 4 years ago · Juan Pablo Isaza Report

0

(await page.$$('.Notifications_banner-notifications li')).length
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!