Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage state not working for preferred pom #2

Open
pmandora-chwy opened this issue Jan 27, 2025 · 0 comments
Open

Storage state not working for preferred pom #2

pmandora-chwy opened this issue Jan 27, 2025 · 0 comments

Comments

@pmandora-chwy
Copy link

in global setup ts i wrote the code login and storage state login

import { getPage, setPage } from '../utils/page-utils';
import * as LoginPage from '../../tests/pages/loginPage';
import * as HomePage from '../../tests/pages/homePage';
import { gotoURL } from 'utils/action-utils';
import { chromium } from '@playwright/test';
import { saveStorageState } from 'utils/element-utils';

async function globalSetup(): Promise {
const browser = await chromium.launch({ headless: true, args: ['--auth-server-allowlist="_"'] });
const context = await browser.newContext();
const page = await context.newPage();
setPage(page)
await gotoURL('https://xxxxxxxd/')
await LoginPage.logInSuccessfully();
await HomePage.verifyHomePageisDisplayed();
await saveStorageState('./playwright/StorageState/LoginAuth.json');

 await browser.close();

}
export default globalSetup;

and in playwright config ts file i had globalsetup parameter and storage state with proper path the file is also getting generated but while running the test its opening the blank page
page setup ts file

baseTest.use({storageState:'./playwright/StorageState/LoginAuth.json'});
baseTest.beforeEach(async ({ page }: { page: Page }) => {
setPage(page);
// setPage(page).context().storageState({ path: './playwright/StorageState/LoginAuth.json' }));
});
its not working then too
spec file
import { test } from "../../src/setup/page-setup";
import * as LoginPage from '../pages/loginPage';
import * as HomePage from '../pages/homePage';
import * as mTaxonomyPage from '../pages/masterTaxonomyPage';

test('Validate for navigating to mtaxo management page from home page',{tag: ['@mTaxonomyTest', '@smoketest']}, async () => {
// await LoginPage.navigateToCumulusLoginPage();
// await LoginPage.logInSuccessfully();
// await HomePage.verifyHomePageisDisplayed();

await HomePage.goToChewyLogo();
await HomePage.navigateToMasterTaxonomy();
await mTaxonomyPage.verifyMasterTaxonomyPageisDisplayed();

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant