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

141
Vistas
Cannot click a button using puppeteer

I am trying to loop through an array to search and add multiple items in cart in https://www.woolworths.com.au/shop/search/ However, after the search the add to cart button simply does not work from Puppetteer. I have tried several ways like using xpath, text, classname and none of them seem to work.

            const [button] = await page.$x("//button[contains(., ' Add to cart ')]");
            if (button) {
                await button.click();
            }

            const buttons = await page.$$('button[class*="cartControls-addButton"]')
            .then(()=>console.log("got buttons"))
            console.log(buttons);
            await buttons[i].click();
            
            let button = await page.$x('//*[@id="search-content"]/div/wow-product-search-container/shared-grid/div/div[1]/shared-product-tile/section/footer/div/shared-cart-controls/div/shared-cart-buttons/div/div/div/div/button/span')
            console.log(button);
            
            const linkHandlers = await page.$x("//a[contains(text(), ' Add to cart ')]");

            if (linkHandlers.length > 0) {
              await linkHandlers[0].click();
            } else {
              throw new Error("Link not found");
            }

Can you please let me know what my issue is? I also have all of my code in this repo .

about 4 years ago · Juan Pablo Isaza
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