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

125
Vistas
How to check if specific action made a request using playwright?

It's my first time using Playwright and I just can't figure out how to check if a request is made to the server. I want to press a button that sends request and and validate if it was successful or not. I am using chromium from Playwright and making tests with Mocha and Chai. This is my code:

const browser = await chromium.launch();    
const page = await browser.newPage();

await page.goto(url);
await page.click('text=Send');
// Validate if the request is send

await browser.close();

I may be trying to do it wrong, but I don't have much experience with Playwright, so any help will be appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I'm not sure I have it clear. As I see it, you'd need to make the requests to the API. You can check it in the docs. For example, after clicking the button:

test('api', async({ request }) => {
    const browser = await chromium.launch();
    const page = await browser.newPage();
    await page.goto(url);
    await page.click('text=Send');
    // your api call(s)
    const req = await request.YOUR_REQ_METHOD('https://THE_URL_NEEDED');
    // your assertion(s)
    expect(req.ok()).toBeTruthy();
});

I'd just add, and I'm not saying this is the case, always consider if you need the use of a browser for achieving your goal.

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