<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v1.35.0]</li>
<li>Operating System: [Debian Bookworm]</li>
<li>Browser: [Chromium]</li>
<li>Other info: Python 3.11</li>
</ul>
<h3 dir="auto">Source code</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I provided exact source code that allows reproducing the issue locally.</li>
</ul>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from playwright.sync_api import sync_playwright

import time
import sys

with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()
    page.goto(&quot;https://paste.ononoki.org/&quot;)

    page.locator('xpath=//textarea[@id=&quot;message&quot;]').type(&quot;HELLO WORLD&quot;)
    page.get_by_role(&quot;button&quot;, name=&quot;send&quot;).click()
    page.wait_for_load_state()
    print(page.url)

    time.sleep(10)
    browser.close()
sys.exit()"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">playwright</span>.<span class="pl-s1">sync_api</span> <span class="pl-k">import</span> <span class="pl-s1">sync_playwright</span>

<span class="pl-k">import</span> <span class="pl-s1">time</span>
<span class="pl-k">import</span> <span class="pl-s1">sys</span>

<span class="pl-k">with</span> <span class="pl-en">sync_playwright</span>() <span class="pl-k">as</span> <span class="pl-s1">p</span>:
    <span class="pl-s1">browser</span> <span class="pl-c1">=</span> <span class="pl-s1">p</span>.<span class="pl-s1">chromium</span>.<span class="pl-en">launch</span>(<span class="pl-s1">headless</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)
    <span class="pl-s1">page</span> <span class="pl-c1">=</span> <span class="pl-s1">browser</span>.<span class="pl-en">new_page</span>()
    <span class="pl-s1">page</span>.<span class="pl-en">goto</span>(<span class="pl-s">"https://paste.ononoki.org/"</span>)

    <span class="pl-s1">page</span>.<span class="pl-en">locator</span>(<span class="pl-s">'xpath=//textarea[@id="message"]'</span>).<span class="pl-en">type</span>(<span class="pl-s">"HELLO WORLD"</span>)
    <span class="pl-s1">page</span>.<span class="pl-en">get_by_role</span>(<span class="pl-s">"button"</span>, <span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">"send"</span>).<span class="pl-en">click</span>()
    <span class="pl-s1">page</span>.<span class="pl-en">wait_for_load_state</span>()
    <span class="pl-en">print</span>(<span class="pl-s1">page</span>.<span class="pl-s1">url</span>)

    <span class="pl-s1">time</span>.<span class="pl-en">sleep</span>(<span class="pl-c1">10</span>)
    <span class="pl-s1">browser</span>.<span class="pl-en">close</span>()
<span class="pl-s1">sys</span>.<span class="pl-en">exit</span>()</pre></div>
<p dir="auto"><strong>Steps</strong></p>
<ul dir="auto">
<li>[Run the test]</li>
</ul>
<p dir="auto"><strong>Expected</strong></p>
<p dir="auto">The actual target URL (ie. where the button takes you) should be printed.</p>
<p dir="auto"><strong>Actual</strong></p>
<p dir="auto">The code prints <code class="notranslate">https://paste.ononoki.org/</code> rather than the target url (eg something like <code class="notranslate">https://paste.ononoki.org/?18f7b2d1ee31024c#BMXkAs1MzWBm5Jot4Yc3XPGFH9sTDXFeFBsBneusvAaZ</code>).</p>
<p dir="auto"><code class="notranslate">page.wait_for_load_state("domcontentloaded")</code> has no effect either.</p>
<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: Version 1.36.1</li>
<li>Operating System: Windows 11</li>
<li>Browser: All</li>
<li>Other info:</li>
</ul>
<h3 dir="auto">Source code</h3>
<p dir="auto">playwright.config.ts:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { defineConfig, devices } from '@playwright/test';

/**
 * See https://playwright.dev/docs/test-configuration.
 */
export default defineConfig({
  testDir: './e2e/playwright/tests/',
  outputDir: './e2e/playwright/test-results/',
  // Run tests in files in parallel
  fullyParallel: true,
  // Fail the build on CI if you accidentally left test.only in the source code.
  forbidOnly: !!process.env.CI,
  // Retry on CI only */
  retries: process.env.CI ? 2 : 0,
  // The maximum number of concurrent worker processes to use for parallelizing tests. Can be set as percentage of logical CPU cores, e.g. '50%'.
  workers: process.env.CI ? '50%' : '50%',
  // Reporter to use. See https://playwright.dev/docs/test-reporters
  reporter: process.env.CI ? 'line' : [['html', { outputFolder: './e2e/playwright/reports/' }]],
  // Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions.

  use: {
    // Base URL to use in actions like `await page.goto('/')`.
    baseURL: process.env.WEBAPP_URL || 'https://dev-cropmanager.vfltest.dk/#/',
    // Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer
    trace: 'on-first-retry',
  },

  // Configure projects for major browsers
  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },

    {
      name: 'firefox',
      use: { ...devices['Desktop Firefox'] },
    },
  ],
});

"><pre class="notranslate"><code class="notranslate">import { defineConfig, devices } from '@playwright/test';

/**
 * See https://playwright.dev/docs/test-configuration.
 */
export default defineConfig({
  testDir: './e2e/playwright/tests/',
  outputDir: './e2e/playwright/test-results/',
  // Run tests in files in parallel
  fullyParallel: true,
  // Fail the build on CI if you accidentally left test.only in the source code.
  forbidOnly: !!process.env.CI,
  // Retry on CI only */
  retries: process.env.CI ? 2 : 0,
  // The maximum number of concurrent worker processes to use for parallelizing tests. Can be set as percentage of logical CPU cores, e.g. '50%'.
  workers: process.env.CI ? '50%' : '50%',
  // Reporter to use. See https://playwright.dev/docs/test-reporters
  reporter: process.env.CI ? 'line' : [['html', { outputFolder: './e2e/playwright/reports/' }]],
  // Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions.

  use: {
    // Base URL to use in actions like `await page.goto('/')`.
    baseURL: process.env.WEBAPP_URL || 'https://dev-cropmanager.vfltest.dk/#/',
    // Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer
    trace: 'on-first-retry',
  },

  // Configure projects for major browsers
  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },

    {
      name: 'firefox',
      use: { ...devices['Desktop Firefox'] },
    },
  ],
});


</code></pre></div>
<p dir="auto">authtest.spec.ts:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { expect, test } from '@playwright/test';

test.use({ storageState: './e2e/playwright/.auth/premium.json' });

test('basic test', async ({ page }) =&gt; {
  await page.goto('./');

  await expect(page).toHaveTitle(/CropManager/);
});"><pre class="notranslate"><code class="notranslate">import { expect, test } from '@playwright/test';

test.use({ storageState: './e2e/playwright/.auth/premium.json' });

test('basic test', async ({ page }) =&gt; {
  await page.goto('./');

  await expect(page).toHaveTitle(/CropManager/);
});
</code></pre></div>
<p dir="auto">auth.setup.ts:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import { expect, test as setup } from '@playwright/test';

const premiumFile = './e2e/playwright/.auth/premium.json';

setup('authenticate as premium user', async ({ page }) =&gt; {
  // Perform authentication steps. Replace these actions with your own.
  await page.goto('./');
  await page.getByRole('button', { name: 'LOG PÅ CROPMANAGER' }).click();

  await page.getByLabel('Brugerkonto').fill('PublicUser');
  await page.getByLabel('Adgangskode').fill('WeLoveTestCafe');
  await page.getByRole('button', { name: 'Log på' }).click();
  // Wait until the page receives the cookies.
  //
  // Sometimes login flow sets cookies in the process of several redirects.
  // Wait for the final URL to ensure that the cookies are actually set.
  await page.waitForURL('https://dev-cropmanager.vfltest.dk/#/');
  await expect(page.getByRole('button', { name: 'LOG PÅ CROPMANAGER' })).toBeVisible();

  // End of authentication steps.
  await page.context().storageState({ path: premiumFile });
});
"><pre class="notranslate"><code class="notranslate">import { expect, test as setup } from '@playwright/test';

const premiumFile = './e2e/playwright/.auth/premium.json';

setup('authenticate as premium user', async ({ page }) =&gt; {
  // Perform authentication steps. Replace these actions with your own.
  await page.goto('./');
  await page.getByRole('button', { name: 'LOG PÅ CROPMANAGER' }).click();

  await page.getByLabel('Brugerkonto').fill('PublicUser');
  await page.getByLabel('Adgangskode').fill('WeLoveTestCafe');
  await page.getByRole('button', { name: 'Log på' }).click();
  // Wait until the page receives the cookies.
  //
  // Sometimes login flow sets cookies in the process of several redirects.
  // Wait for the final URL to ensure that the cookies are actually set.
  await page.waitForURL('https://dev-cropmanager.vfltest.dk/#/');
  await expect(page.getByRole('button', { name: 'LOG PÅ CROPMANAGER' })).toBeVisible();

  // End of authentication steps.
  await page.context().storageState({ path: premiumFile });
});

</code></pre></div>
<p dir="auto">Folder structure:<br>
e2e/playwright/.auth<br>
e2e/playwright/tests/auth.setup.ts<br>
e2e/playwright/tests/authtest.spec.ts<br>
playwright.config.ts</p>
<p dir="auto"><strong>Steps</strong></p>
<ul dir="auto">
<li>Run the test with provided auth (multiple roles login)</li>
</ul>
<p dir="auto"><strong>Expected</strong></p>
<p dir="auto">Expected a premium.json to be created in .auth folder when test was run.<br>
It seems the auth.setup.ts is never run - Am i missing something in configuration? Documentation doesn't state it.<br>
If I for instance comment out this line, the test will pass: // test.use({ storageState: './e2e/playwright/.auth/premium.json' });</p>
<p dir="auto"><strong>Actual</strong></p>
<p dir="auto">Error: Error reading storage state from ./e2e/playwright/.auth/premium.json:<br>
ENOENT: no such file or directory</p>