You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two GET requests are intercepted, interceptionsCount variable equal 2
Actual behavior
Only one GET request is intercepted, interceptionsCount variable equal 1
Additional context
I want to test a web service protected by a token-based auth, so all requests must have an "X-Auth" header with a secret value.
Recently we added ability to download files, so I wrote an e2e test and it failed because when Playwright clicks on the <a href="/artifact.zip" download>Download link</a> link - it doesn't add the header, so server responds with 403 Forbidden and the test fails. I expect that the both setExtraHTTPHeaders and route methods should handle all requests, including download ones.
In my example repo, I am trying to intercept an archive download request:
test('Download intercept issue',async({ page, context })=>{letinterceptionsCount=0;awaitcontext.route('https://denis-domanskii.github.io/playwright-download-intercept-issue/archive.zip',asyncroute=>{interceptionsCount++;awaitroute.continue();});awaitpage.goto('https://denis-domanskii.github.io/playwright-download-intercept-issue/');// FAIL: <a> tag with download is invisible for DevTools and Playwright interceptconstdownloadPromise1=page.waitForEvent('download');awaitpage.getByText("Download (with 'download' attr)").click();awaitdownloadPromise1;// SUCCESS: <a> tag with download is visible for DevTools and Playwright interceptconstdownloadPromise2=page.waitForEvent('download');awaitpage.getByText("Download (without 'download' attr)").click();awaitdownloadPromise2;expect(interceptionsCount).toBe(2);});
As I can't provide logs from the server side with a proof that there were no the 'X-Auth' header, I added the interceptionsCount variable incrementing each time when a request to the zip archive is intercepted. So, it intercepted 1 times instead of 2 and the test fails.
context.setExtraHTTPHeaders() also doesn't work, I checked it using logs of my server - there were no added header too.
Open Chrome DevTools "Network" tab (make sure that you capturing all requests)
Click the first button
Click the second button
Expected: Two requests are shown in the Network tab Observed: Only one request is shown in the Network tab
So, could you please confirm that it's a Chrome issue and there is no way to handle it on Playwright side?
Chromium issue is raised too: https://issues.chromium.org/issues/338842124
Version
1.43.1
Steps to reproduce
npm install
npm run test
Expected behavior
Two GET requests are intercepted, interceptionsCount variable equal 2
Actual behavior
Only one GET request is intercepted, interceptionsCount variable equal 1
Additional context
I want to test a web service protected by a token-based auth, so all requests must have an "X-Auth" header with a secret value.
Recently we added ability to download files, so I wrote an e2e test and it failed because when Playwright clicks on the
<a href="/artifact.zip" download>Download link</a>
link - it doesn't add the header, so server responds with403 Forbidden
and the test fails. I expect that the bothsetExtraHTTPHeaders
androute
methods should handle all requests, including download ones.In my example repo, I am trying to intercept an archive download request:
As I can't provide logs from the server side with a proof that there were no the 'X-Auth' header, I added the
interceptionsCount
variable incrementing each time when a request to the zip archive is intercepted. So, it intercepted 1 times instead of 2 and the test fails.context.setExtraHTTPHeaders()
also doesn't work, I checked it using logs of my server - there were no added header too.Environment
The text was updated successfully, but these errors were encountered: