Last active
March 28, 2023 21:51
-
-
Save corradin/7632ea89e37ba895e828a13445f1544d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { chromium } from '@playwright/test'; | |
import login from './utils/login'; | |
const username = process.env.MEETUP_USERNAME ?? ''; | |
const password = process.env.MEETUP_PASSWORD ?? ''; | |
async function globalSetup(config: FullConfig): Promise<void> { | |
const { storageState } = config.projects[0].use; | |
// TODO: Remove headless after this has been tested | |
const browser = await chromium.launch({ headless: false }); | |
const page = await browser.newPage(); | |
await login(page, username, password); | |
await page.context().storageState({ | |
path: storageState, | |
}); | |
await browser.close(); | |
} | |
export default globalSetup; |
@corradin It doesn't save the storageState to the designated path either which is making my test fail. Thanks for the help!
Global set up updated
import { chromium, FullConfig } from '@playwright/test';
import login from './tests/utils/login';
const username = process.env.PLAYWRIGHT_USERNAME ?? '';
const password = process.env.PLAYWRIGHT_PASSWORD ?? '';
async function globalSetup(config: FullConfig): Promise<void> {
const { storageState } = config.projects[0].use;
// TODO: Remove headless after this has been tested
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
await login(page, username, password);
await page.context().storageState({
path: storageState as string,
});
console.log(storageState);
await browser.close();
}
export default globalSetup;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @corradin, I was using your examples and reading article you posted. I am running into an issue where it complains of path on line 14 locally. Thanks in advance for all your help!
Config file