0

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.

1 Answer 1

1

It appears the culprit is that the click methods aren’t actually being called, you’re just referencing the methods themselves. So the fix hopefully is just putting () after .click which should at least correct that and make sure the clicks are actually happening.

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.