Search code examples
javascripttypescriptplaywrightplaywright-typescript

Getting Error: page.goto: Test ended. in playwright


I am trying to create a function like this in playwright. By the way, I am new to playwright.

import { expect } from "@playwright/test";
import { EnvCredentials } from "../helpers/getEnvCredentials";

export class PW {
    static async visit(page, routeName) {
       await page.goto(EnvCredentials.getCredsValue("BASE_URL") + routeName);
    }
}

That visit() method above is being called in this function

static async uiLogin(username, password, page) {
   const loginPage = new LoginPage(page);

   PW.visit(page, route_root_page);
   await loginPage.enterUsername(username);
   await loginPage.enterPassword(password);
   await loginPage.clickLoginBtn();
}

Upon running, I am getting this error

Error: page.goto: Test ended. Call log:

  • navigating to "https://latest.frankiefinancial.io/", waiting until "load" at portal\helpers\playwrightMethods.ts:6 4 | export class PW { 5 | static async visit(page, routeName) { 6 | await page.goto(EnvCredentials.getCredsValue("BASE_URL") + routeName); | ^ 7 | } 8 |

enter image description here


Solution

  • Your visit function is async so you should wait for it to complete in your test await PW.visit(page, route_root_page);.