type TestOptions = { username: string; password: string; }
export default defineConfig<TestOptions>({ ...... projects: [ { name: 'setup', testMatch: /login.setup.ts/, }, { name: 'production', use: { ...devices['Desktop Chrome'], baseURL: 'xxx', username: 'xxx', password: 'xxx', storageState: '.auth/user.json', }, dependencies: ['setup'], }, });
setup('xxx', async ({ page }) => { await page.goto('/distribute'); await page.locator('input[name="account"]').fill(process.env.username!); await page.locator('input[name="password"]').fill(process.env.password!); ...... })
When I use process.env.username, I cannot get the value of username.
This thread is trying to answer question "How can I get the value of a variable from the 'use' attribute in projects in the playwright.config.ts file?"
ok, thanks. I'll look at the youtube video for a .env solution first. But I'd like to dig a little deeper to see if there's a way to get a variable in the custom project parameter
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].