I am trying to implement POM in playwright, I have created a class in which I am trying to click two buttons to navigate to a page and then apply URL assertion to check the expected URL. But the URL of the Page isn't changing and the assertion is getting failed. here is the class code:
exports.HomePage = class HomePage {
constructor(page) {
this.page = page
this.login_button = page.getByRole('button', { name: 'Login' })
this.client_login_button = page.getByRole(('link', { name: 'CLIENT LOGIN' }))
}
async gotoHomePage(){
await this.page.goto('https://plentifulapp.com/');
await this.login_button.click
await this.client_login_button.click
}
} and here is the main test file.
test.only('ValidLogin', async ({ page }) => {
const Home = new HomePage(page);
await Home.gotoHomePage();
await expect(page).toHaveURL('https://app.plentifulapp.com/a/pantries')
Asserting applied in main test file in getting failed.