<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v1.35]</li>
<li>Operating System: [Windows 11]</li>
<li>Browser: [Chromium]</li>
<li>Other info:</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="
import time
import re
import asyncio
from playwright.async_api import async_playwright

def handle_request(req, ):
    global code
    url_regex = re.compile(r&quot;xfinitydigitalhome://auth\?&quot;)
    try:
        url = req.headers['location']
        print('response url:' + req.url)
        if url_regex.search(url):
            print(&quot;Request URL:&quot;, url)

            regexp_1 = r'&amp;code=(.*)'
            match_2 = re.search(regexp_1, url)
            code = match_2.group(1)
            print(&quot;code&quot;)
            print(code)
            return code
    except:
        pass

async def main():
        async with async_playwright() as pw:
        url = 'https://xerxes-sub.xerxessecure.com/xerxes-ctrl/oauth/authorize?redirect_uri=xfinitydigitalhome%3A%2F%2Fauth&amp;client_id=xfinity-digital-home&amp;response_type=code&amp;prompt=select_account&amp;state=pcmI1pOdQC-sF-b2XSyNhg&amp;code_challenge=plBIQIkEAuywK76tE4uTPI7yGIU0OTOjuvQHnlB7c3Q&amp;code_challenge_method=S256&amp;rm_hint=true&amp;partner_id=comcast&amp;mso_partner_hint=true'

        browser = await pw.chromium.launch(headless=False)
        context = await browser.new_context(
          proxy={
              'server': 'http://sample.com:port',  # replace with your proxy server and port
              'username': 'username',  # replace with your username
              'password': 'passwd'
          }, ignore_https_errors=True)
        page = await context.new_page()
        page.set_default_navigation_timeout(0)
        page.on(&quot;response&quot;, handle_request)
        print('goto: ' + url)
        await page.goto(url,
                        timeout=0, wait_until=&quot;networkidle&quot;)
        await page.wait_for_selector('#user', timeout=30000)
        await page.type('#user', username)
        print('type username')
        await page.click('#sign_in')
        time.sleep(60)
        await browser.close()

asyncio.get_event_loop().run_until_complete(main())"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">time</span>
<span class="pl-k">import</span> <span class="pl-s1">re</span>
<span class="pl-k">import</span> <span class="pl-s1">asyncio</span>
<span class="pl-k">from</span> <span class="pl-s1">playwright</span>.<span class="pl-s1">async_api</span> <span class="pl-k">import</span> <span class="pl-s1">async_playwright</span>

<span class="pl-k">def</span> <span class="pl-en">handle_request</span>(<span class="pl-s1">req</span>, ):
    <span class="pl-k">global</span> <span class="pl-s1">code</span>
    <span class="pl-s1">url_regex</span> <span class="pl-c1">=</span> <span class="pl-s1">re</span>.<span class="pl-en">compile</span>(<span class="pl-s">r"xfinitydigitalhome://auth\?"</span>)
    <span class="pl-k">try</span>:
        <span class="pl-s1">url</span> <span class="pl-c1">=</span> <span class="pl-s1">req</span>.<span class="pl-s1">headers</span>[<span class="pl-s">'location'</span>]
        <span class="pl-en">print</span>(<span class="pl-s">'response url:'</span> <span class="pl-c1">+</span> <span class="pl-s1">req</span>.<span class="pl-s1">url</span>)
        <span class="pl-k">if</span> <span class="pl-s1">url_regex</span>.<span class="pl-en">search</span>(<span class="pl-s1">url</span>):
            <span class="pl-en">print</span>(<span class="pl-s">"Request URL:"</span>, <span class="pl-s1">url</span>)

            <span class="pl-s1">regexp_1</span> <span class="pl-c1">=</span> <span class="pl-s">r'&amp;code=(.*)'</span>
            <span class="pl-s1">match_2</span> <span class="pl-c1">=</span> <span class="pl-s1">re</span>.<span class="pl-en">search</span>(<span class="pl-s1">regexp_1</span>, <span class="pl-s1">url</span>)
            <span class="pl-s1">code</span> <span class="pl-c1">=</span> <span class="pl-s1">match_2</span>.<span class="pl-en">group</span>(<span class="pl-c1">1</span>)
            <span class="pl-en">print</span>(<span class="pl-s">"code"</span>)
            <span class="pl-en">print</span>(<span class="pl-s1">code</span>)
            <span class="pl-k">return</span> <span class="pl-s1">code</span>
    <span class="pl-k">except</span>:
        <span class="pl-k">pass</span>

<span class="pl-k">async</span> <span class="pl-k">def</span> <span class="pl-en">main</span>():
        <span class="pl-k">async</span> <span class="pl-k">with</span> <span class="pl-en">async_playwright</span>() <span class="pl-k">as</span> <span class="pl-s1">pw</span>:
        <span class="pl-s1">url</span> <span class="pl-c1">=</span> <span class="pl-s">'https://xerxes-sub.xerxessecure.com/xerxes-ctrl/oauth/authorize?redirect_uri=xfinitydigitalhome%3A%2F%2Fauth&amp;client_id=xfinity-digital-home&amp;response_type=code&amp;prompt=select_account&amp;state=pcmI1pOdQC-sF-b2XSyNhg&amp;code_challenge=plBIQIkEAuywK76tE4uTPI7yGIU0OTOjuvQHnlB7c3Q&amp;code_challenge_method=S256&amp;rm_hint=true&amp;partner_id=comcast&amp;mso_partner_hint=true'</span>

        <span class="pl-s1">browser</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">pw</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">context</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">browser</span>.<span class="pl-en">new_context</span>(
          <span class="pl-s1">proxy</span><span class="pl-c1">=</span>{
              <span class="pl-s">'server'</span>: <span class="pl-s">'http://sample.com:port'</span>,  <span class="pl-c"># replace with your proxy server and port</span>
              <span class="pl-s">'username'</span>: <span class="pl-s">'username'</span>,  <span class="pl-c"># replace with your username</span>
              <span class="pl-s">'password'</span>: <span class="pl-s">'passwd'</span>
          }, <span class="pl-s1">ignore_https_errors</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
        <span class="pl-s1">page</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">context</span>.<span class="pl-en">new_page</span>()
        <span class="pl-s1">page</span>.<span class="pl-en">set_default_navigation_timeout</span>(<span class="pl-c1">0</span>)
        <span class="pl-s1">page</span>.<span class="pl-en">on</span>(<span class="pl-s">"response"</span>, <span class="pl-s1">handle_request</span>)
        <span class="pl-en">print</span>(<span class="pl-s">'goto: '</span> <span class="pl-c1">+</span> <span class="pl-s1">url</span>)
        <span class="pl-k">await</span> <span class="pl-s1">page</span>.<span class="pl-en">goto</span>(<span class="pl-s1">url</span>,
                        <span class="pl-s1">timeout</span><span class="pl-c1">=</span><span class="pl-c1">0</span>, <span class="pl-s1">wait_until</span><span class="pl-c1">=</span><span class="pl-s">"networkidle"</span>)
        <span class="pl-k">await</span> <span class="pl-s1">page</span>.<span class="pl-en">wait_for_selector</span>(<span class="pl-s">'#user'</span>, <span class="pl-s1">timeout</span><span class="pl-c1">=</span><span class="pl-c1">30000</span>)
        <span class="pl-k">await</span> <span class="pl-s1">page</span>.<span class="pl-en">type</span>(<span class="pl-s">'#user'</span>, <span class="pl-s1">username</span>)
        <span class="pl-en">print</span>(<span class="pl-s">'type username'</span>)
        <span class="pl-k">await</span> <span class="pl-s1">page</span>.<span class="pl-en">click</span>(<span class="pl-s">'#sign_in'</span>)
        <span class="pl-s1">time</span>.<span class="pl-en">sleep</span>(<span class="pl-c1">60</span>)
        <span class="pl-k">await</span> <span class="pl-s1">browser</span>.<span class="pl-en">close</span>()

<span class="pl-s1">asyncio</span>.<span class="pl-en">get_event_loop</span>().<span class="pl-en">run_until_complete</span>(<span class="pl-en">main</span>())</pre></div>
<p dir="auto"><strong>Expected</strong></p>
<p dir="auto">All the network responses should be intercepted in <code class="notranslate">handle_request</code></p>
<p dir="auto"><strong>Actual</strong></p>
<p dir="auto">I set a proxy to playwright as the code that I have listed above, it works, but not all the response are intercepted, some of the requests just weren't shown, I have also tried using <code class="notranslate">page.route</code>, it has the same issue too. I have no idea why, it works fine without a proxy.</p>
<p dir="auto">I am %100 sure some of the requests are sent by the browser, I checked the network tab of Chromium, I saw the requests, but not intercepted by playwright.</p>
<p dir="auto"><strong>Context:</strong></p>
<ul dir="auto">
<li>Playwright Version:1.29.1</li>
<li>Operating System: Windows</li>
<li>Node.js version:v16.13.0</li>
<li>Browser: [e.g. All, Chromium, Firefox, WebKit] WebKit</li>
<li>Extra: [any specific details about your environment]</li>
</ul>
<p dir="auto">Pre-requisites:<br>
Create a copy of example.spec.ts and just rename the test name<br>
Create another test in second file (I have just copied the same test and updated the test name)<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/57455260/209997864-2f223bce-64da-467c-8475-0de8f72cb1fe.png"><img src="https://user-images.githubusercontent.com/57455260/209997864-2f223bce-64da-467c-8475-0de8f72cb1fe.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">Steps to reproduce:</p>
<ol dir="auto">
<li>Select Default Profile as Webkit<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/57455260/209997232-242b8caa-47e4-4641-9a38-79d4c32993aa.png"><img src="https://user-images.githubusercontent.com/57455260/209997232-242b8caa-47e4-4641-9a38-79d4c32993aa.png" alt="image" style="max-width: 100%;"></a></li>
<li>Click on Run all icon</li>
<li>Notice that, first test passed but second and third tests failed<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/57455260/209997639-771df1c5-4e24-4164-8b55-881eae417ca5.png"><img src="https://user-images.githubusercontent.com/57455260/209997639-771df1c5-4e24-4164-8b55-881eae417ca5.png" alt="image" style="max-width: 100%;"></a><br>
Error details:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/57455260/209997697-dfe1172d-7f0b-49a6-abda-e962545cbfae.png"><img src="https://user-images.githubusercontent.com/57455260/209997697-dfe1172d-7f0b-49a6-abda-e962545cbfae.png" alt="image" style="max-width: 100%;"></a></li>
</ol>