I have noticed with issue only with 1.4 version of playwright. Does not happen in 1.39.
Has anything changed in how apiRequestContext is shared between beforeAll and test?
Example:
let apiClass;
test.beforeAll(async ({ request }) => {
apiClass = new ApiClass(requst);
... do something ...
});
test('first test', async () => {
await apiClass.doSomething();
});
when apiClass method is called within test, the following error shows only in playwright 1.4: Error: apiRequestContext.storageState: Target page, context or browser has been closed
If i reinitialize apiClass within test, error disappears
This thread is trying to answer question "Has the way apiRequestContext is shared between beforeAll and tests changed in Playwright 1.4, and how should it be correctly initialized?"
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].