-
Notifications
You must be signed in to change notification settings - Fork 19
Description
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();
});