I created a single test file for the functionality of one page, Im using Page Object Model and used 3 different describe blocks for different sections of the page in the one file.
When running the tests the first describe block runs as expected but then each describe block after that fails to login.
When i run each describe block individually they all pass.
I'm not sure if this is an issue with playwright or an issue with how i have written the tests. Any help would be appreciated
This thread is trying to answer question "Why do subsequent 'describe' blocks fail to login in a single test file using the Page Object Model?"
Hi, I have the same issue, I get these kind of errors:
ration file.,
- You are calling ${title} in a file that is imported by the configuration file.,
- You have two different versions of @playwright/test. This usually happens,
when one of the dependencies in your package.json depends on @playwright/test.`].join('\n'));
^
Error: Playwright Test did not expect test() to be called here. Most common reasons include:
Here is an example of one of them test.beforeEach(async ({ page }) => { await page.goto("/"); await expect(page.getByRole("button", { name: "autotest" })).toBeVisible(); const dashboard = new dashboardPage(page); await dashboard.organizationDropDown.click(); await dashboard.selectOrganization.click(); await page.locator(".MuiPopover-root > div").first().click(); const closeNotificationBox = await page.$('div:has-text("View") >> svg'); if (closeNotificationBox != null) { await closeNotificationBox.click(); } });
test.afterEach(async ({ page }) => { await page.close() })
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].