October 21, 2024
Chicago 12, Melborne City, USA
javascript

Running into “Target page, context or browser has been closed” issue


The below code is my Playwright test function

    test("@Login @Testing Sign In Page Test", async ({ page }) => {
        console.log("Sign In Page Test");
 
        const pageManager = new pageObjectManager(page);
        const homePage = pageManager.getHomePage();
        const loginPage = pageManager.getLoginPage();
        const signInPage = pageManager.getSignInPage();

        // await homePage.goToHomePage();
        await page.goto("https://magento.softwaretestingboard.com/");

        // await loginPage.goToSignInPage();
        console.log(await page.title());
        await page.locator("//li[@class="authorization-link"]").first().click();

        // await signInPage.validateLandingOnSignInPage();
        console.log(await page.title());
        await expect(page).toHaveTitle("Customer Login");
    });

This worked for me a few months ago but now, when I am trying to rerun the test case, I run into the below error

Error: page.title: Target page, context or browser has been closed

      34 |
      35 |      // await signInPage.validateLandingOnSignInPage();
    > 36 |      console.log(await page.title());
         |                             ^
      37 |      await expect(page).toHaveTitle("Customer Login");
      38 | });
      39 |

Even when I place the code in functions mentioned in comments just above them, I see the issue.

I am not sure what is causing this fresh issue. Please help me. Thanks in advance.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video