1

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

1
  • 1
    what values are you passing in to the uiLogin function? Is page a Playwright page object? Commented Feb 29, 2024 at 14:07

1 Answer 1

8

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.