<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version:  v1.24.2</li>
<li>Node version: 18.12.1</li>
<li>Operating System:  windows server 2019</li>
<li>Browser: Chromium</li>
</ul>
<h3 dir="auto">Issue</h3>
<p dir="auto">The download event is not triggered when I am using the machine to reach some internal site. If I open the chromium.exe manually, I can download the file with the same button clicked.</p>
<p dir="auto">This issue only happens when I go to the internal sites, if I go to some public website and perform a button click download, the program works well. I have another server running the same node and playwright version with windows server 2016, which can download file no matter which website it is using the same program.</p>
<p dir="auto">I would like to know is there something I configure playwright wrong or only a permission issue. As the code I am using, I only know that I perform a button click successfully and don't know if the download event emit or not.</p>
<h3 dir="auto">Code Snippet</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="   const browser = await chromium.launch({
    headless: true,
    args: [&quot;--no-sandbox&quot;],
    downloadsPath: path_to_data,
    executablePath: path.resolve(
      &quot;./node_modules/chromium/lib/chromium/chrome-win/chrome.exe&quot;  
    ),
  });
  const context = await browser.newContext({acceptDownloads: true });
  const page = await context.newPage();
// some code here
  page.on(&quot;download&quot;, async (dl) =&gt; {
           const downloaded = await dl.path();
           console.log(&quot;Download Finished&quot;);
           var real_file_name = startDate +&quot;_&quot;+ endDate;
          real_file_name = &quot;Download - &quot;+real_file_name.replace(/-/g, '')+&quot;.xlsx&quot;; 
          renameSync(downloaded, `${path_to_data}/${real_file_name}`);
          console.log(&quot;Rename Finished&quot;);
          await browser.close();
          success = true;
         });

  await page.click('button:text(&quot;Export&quot;)', { force: true });
  console.log(&quot;Start Downloading&quot;);
  await new Promise(resolve =&gt; setTimeout(resolve, 10000));"><pre class="notranslate">   <span class="pl-k">const</span> <span class="pl-s1">browser</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">chromium</span><span class="pl-kos">.</span><span class="pl-en">launch</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
    <span class="pl-c1">headless</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
    <span class="pl-c1">args</span>: <span class="pl-kos">[</span><span class="pl-s">"--no-sandbox"</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-c1">downloadsPath</span>: <span class="pl-s1">path_to_data</span><span class="pl-kos">,</span>
    <span class="pl-c1">executablePath</span>: <span class="pl-s1">path</span><span class="pl-kos">.</span><span class="pl-en">resolve</span><span class="pl-kos">(</span>
      <span class="pl-s">"./node_modules/chromium/lib/chromium/chrome-win/chrome.exe"</span>  
    <span class="pl-kos">)</span><span class="pl-kos">,</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">const</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-kos">.</span><span class="pl-en">newContext</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-c1">acceptDownloads</span>: <span class="pl-c1">true</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">const</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-kos">.</span><span class="pl-en">newPage</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">// some code here</span>
  <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">"download"</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-s1">dl</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
           <span class="pl-k">const</span> <span class="pl-s1">downloaded</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">dl</span><span class="pl-kos">.</span><span class="pl-en">path</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
           <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"Download Finished"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
           <span class="pl-k">var</span> <span class="pl-s1">real_file_name</span> <span class="pl-c1">=</span> <span class="pl-s1">startDate</span> <span class="pl-c1">+</span><span class="pl-s">"_"</span><span class="pl-c1">+</span> <span class="pl-s1">endDate</span><span class="pl-kos">;</span>
          <span class="pl-s1">real_file_name</span> <span class="pl-c1">=</span> <span class="pl-s">"Download - "</span><span class="pl-c1">+</span><span class="pl-s1">real_file_name</span><span class="pl-kos">.</span><span class="pl-en">replace</span><span class="pl-kos">(</span><span class="pl-pds"><span class="pl-c1">/</span>-<span class="pl-c1">/</span>g</span><span class="pl-kos">,</span> <span class="pl-s">''</span><span class="pl-kos">)</span><span class="pl-c1">+</span><span class="pl-s">".xlsx"</span><span class="pl-kos">;</span> 
          <span class="pl-en">renameSync</span><span class="pl-kos">(</span><span class="pl-s1">downloaded</span><span class="pl-kos">,</span> <span class="pl-s">`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">path_to_data</span><span class="pl-kos">}</span></span>/<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">real_file_name</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
          <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"Rename Finished"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
          <span class="pl-k">await</span> <span class="pl-s1">browser</span><span class="pl-kos">.</span><span class="pl-en">close</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
          <span class="pl-s1">success</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>
         <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">click</span><span class="pl-kos">(</span><span class="pl-s">'button:text("Export")'</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">force</span>: <span class="pl-c1">true</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"Start Downloading"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">await</span> <span class="pl-k">new</span> <span class="pl-v">Promise</span><span class="pl-kos">(</span><span class="pl-s1">resolve</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">setTimeout</span><span class="pl-kos">(</span><span class="pl-s1">resolve</span><span class="pl-kos">,</span> <span class="pl-c1">10000</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>html</strong></p>
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="		&lt;div class=&quot;row form-group&quot;&gt;
			&lt;span class=&quot;col-3&quot;&gt;&lt;/span&gt; &lt;span class=&quot;col-3&quot;&gt;
				&lt;button class=&quot;btn btn-primary exportable&quot; onclick=&quot;printDownload()&quot;&gt;Download&lt;/button&gt;
			&lt;/span&gt;
		&lt;/div&gt;
"><pre class="notranslate">		<span class="pl-kos">&lt;</span><span class="pl-ent">div</span> <span class="pl-c1">class</span>="<span class="pl-s">row form-group</span>"<span class="pl-kos">&gt;</span>
			<span class="pl-kos">&lt;</span><span class="pl-ent">span</span> <span class="pl-c1">class</span>="<span class="pl-s">col-3</span>"<span class="pl-kos">&gt;</span><span class="pl-kos">&lt;/</span><span class="pl-ent">span</span><span class="pl-kos">&gt;</span> <span class="pl-kos">&lt;</span><span class="pl-ent">span</span> <span class="pl-c1">class</span>="<span class="pl-s">col-3</span>"<span class="pl-kos">&gt;</span>
				<span class="pl-kos">&lt;</span><span class="pl-ent">button</span> <span class="pl-c1">class</span>="<span class="pl-s">btn btn-primary exportable</span>" <span class="pl-c1">onclick</span>="<span class="pl-s">printDownload()</span>"<span class="pl-kos">&gt;</span>Download<span class="pl-kos">&lt;/</span><span class="pl-ent">button</span><span class="pl-kos">&gt;</span>
			<span class="pl-kos">&lt;/</span><span class="pl-ent">span</span><span class="pl-kos">&gt;</span>
		<span class="pl-kos">&lt;/</span><span class="pl-ent">div</span><span class="pl-kos">&gt;</span></pre></div>
<p dir="auto">When I run the internal site, the code will stop at Start Downloading and then end whten the timeout end, while when the code is run on another server, it will trigger the download event.</p>
<p dir="auto">Playwright trace is very helpful in debugging, it shows the dom snapshots as well.<br>
But if my locator has issues, I'd like to have the capability of using query engine on the dom snapshot in <a href="https://trace.playwright.dev/" rel="nofollow">https://trace.playwright.dev/</a> (on the same browser instance where <a href="https://trace.playwright.dev/" rel="nofollow">https://trace.playwright.dev/</a> is running)</p>
<p dir="auto">it will save time.</p>
<p dir="auto">Currently I resort to Playwright Inspector / Codegen and replay my test up to that point.</p>