You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using Playwright testing library for our test framework, and it is really helpful, now we are trying to do authentication once then reuse session storage, storage state (cookies) for the rest of the tests instead of manually logging in every time.
I am able to capture session storage and reuse it for logging in and perform only playwright page queries , not able to execute screen queries(eg: queryByTestId())..
i see the test opens a blank page and the other page with the actual URL.
looks like the issue is that the screen fixture opens up a blank page, and it is searching for the locator on the blank page.
if i remove screen fixture from the code below, it works ok, but adding a screen fixture opens up a blank page, and queryByTestId() is looking to search for the element on the blank page, instead of searching the element on the other window that opens the actual URL.
Can you please advise how to get rid of the blank page or how to make screen point to the actual page instead of the blank page? Can you please assist?
constbase=require("@playwright/test");import{locatorFixturesasfixtures}from'@playwright-testing-library/test/fixture';constit=base.test.extend(fixtures);const{expect}=it;import{UseBidAndAwardActor}from'../web/actors/BidAndAwardActors';importEnvfrom"../web/utils/Env"exportconsttest=it.extend({crewIFPlannerActor: async({browser, context, screen},use)=>{context=awaitbrowser.newContext({storageState: './storage-state2.json'});constsessionStorage=process.env.SESSION_STORAGE;awaitcontext.addInitScript(storage=>{constentries=JSON.parse(storage);Object.keys(entries).forEach(key=>{window.sessionStorage.setItem(key,entries[key]);});},sessionStorage);//adding session storage to the context and creating a page using that context, to avoid manual login.constpage=awaitcontext.newPage({ignoreHTTPSErrors: true});// this initializes screen in the constructor,constcrewIFPlannerActor=UseBidAndAwardActor(page,page,'IF Planner Actor',`${Env.IF_PLANNER_USERNAME}`,`${Env.IF_PLANNER_PASSWORD}`,screen,page);crewIFPlannerActor.with('page',page);crewIFPlannerActor.with('screen',screen);crewIFPlannerActor.with('within',page);awaituse(crewIFPlannerActor);},});export{expect}from'@playwright/test';
We are using Playwright testing library for our test framework, and it is really helpful, now we are trying to do authentication once then reuse session storage, storage state (cookies) for the rest of the tests instead of manually logging in every time.
here is the link for reference.
https://playwright.dev/docs/auth
I am able to capture session storage and reuse it for logging in and perform only playwright page queries , not able to execute screen queries(eg: queryByTestId())..
i see the test opens a blank page and the other page with the actual URL.
looks like the issue is that the screen fixture opens up a blank page, and it is searching for the locator on the blank page.
if i remove screen fixture from the code below, it works ok, but adding a screen fixture opens up a blank page, and queryByTestId() is looking to search for the element on the blank page, instead of searching the element on the other window that opens the actual URL.
Can you please advise how to get rid of the blank page or how to make screen point to the actual page instead of the blank page? Can you please assist?
Test:
The text was updated successfully, but these errors were encountered: