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

299
Vistas
Playwright js - im trying to validate when clicking on a button it opens a new tab , then validates the title

So i have written a function that in short clicks an FAQs button and validate that the new tab is open on the same browser Context. the issue i have when running my test is i get:

TypeError: Cannot read property 'title' of undefined

Heres my function - PATH src/tests/rms/logoutAndFaqs.spec.ts:

async shouldSeeFaqsInNewTab() {
     const browserName = await chromium.launch();
     const context = await browserName.newContext();
     const pages = await context.pages();

     await this.click(HomeScreen.faqButton);
     await this.page.waitForTimeout(1000);

     expect(await pages[1].title())?.toBe("Title");
  }

and heres is the function getting called - PATH src/pages/rms/rmsHome.page.ts:

import test from "../../helpers/base.page";

test.describe("Ensure you land on the home page when logged in", () => {
  test.beforeEach(async ({ rmsHome }) => {
    await rmsHome.gotoRmsHomePage();
  });

  test.only("Validate that FAQs opens in a new tab", async ({ rmsHome }) => {
    await rmsHome.shouldSeeFaqsInNewTab();
  });
});

i know that this line expect(await pages[1].title())?.toBe("Title") specifically is accessing the tab opened within the window and within the browserContext its validating the title expecting a string to equal "Title".

specifically title() is causing an error due to being an unassign value. im trying to understand why this error? and how to fix it. thanks

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