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

231
Vistas
Playwright browser is reopening every test statement

How to stop browser from reopening every time the the every test statement is done? I mean the code below is supposedly in 1 page continuing. Why is it the browser closes, open again and execute the second test. How to prevent that? Thanks


  test('When user logs in', async ({page}) => {
    const commonAction = new CommonAction();
    await commonAction.gotoPage(page);
    await expect(page).toHaveURL('https://uat.mercator.createit.dev/login');
    await commonAction.login( page, janEmail, janPasswd );
  });

  test('Then user is in my account page', async ({page}) => {
    const navigationAction = new NavigationAction();
    await navigationAction.verifyAccountPage(page);  
  });
  
  test('When user goes to newsletter subscriptions', async ({page}) => {
    const navigationAction = new NavigationAction();
    await navigationAction.goToNewsSubscription(page);  
  });

  test('Then user is in Newsletter subscription page', async ({page}) => {
    const navigationAction = new NavigationAction();
    await navigationAction.verifyNewsletterPage(page);  
  });

  test('When user updates subscription', async ({page}) => {
    const newsletterAction = new NewsletterAction();
    newsletterAction.subscribe(page);
  });

  test('Then user is redirected to My Account page after subscription updates', async ({page}) => {
    const navigationAction = new NavigationAction();
    await navigationAction.verifyAccountPage();
  }); 
})```
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

For the tests that share the same page and rely on the previous test results you need to wrap them in test.describe.serial and initialize the page in beforeAll, see this guide for more information.

Your example would look like this:

const { test } = require('@playwright/test');

test.describe.serial('use the same page', () => {
  /** @type {import('@playwright/test').Page} */
  let page;

  test.beforeAll(async ({ browser }) => {
    page = await browser.newPage();
  });

  test.afterAll(async () => {
    await page.close();
  });

  test('When user logs in', async ({}) => {
    const commonAction = new CommonAction();
    await commonAction.gotoPage(page);
    await expect(page).toHaveURL('https://uat.mercator.createit.dev/login');
    await commonAction.login( page, janEmail, janPasswd );
  });

  test('Then user is in my account page', async ({}) => {
    const navigationAction = new NavigationAction();
    await navigationAction.verifyAccountPage(page);  
  });
  
  test('When user goes to newsletter subscriptions', async ({}) => {
    const navigationAction = new NavigationAction();
    await navigationAction.goToNewsSubscription(page);  
  });

  test('Then user is in Newsletter subscription page', async ({}) => {
    const navigationAction = new NavigationAction();
    await navigationAction.verifyNewsletterPage(page);  
  });

  test('When user updates subscription', async ({}) => {
    const newsletterAction = new NewsletterAction();
    newsletterAction.subscribe(page);
  });

  test('Then user is redirected to My Account page after subscription updates', async ({}) => {
    const navigationAction = new NavigationAction();
    await navigationAction.verifyAccountPage();
  }); 
});
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