Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

296
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda