Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!