# PDF Screenshot Issue: Different Behavior Local vs Elastic Synthetics Server

**URL:** <https://discuss.elastic.co/t/pdf-screenshot-issue-different-behavior-local-vs-elastic-synthetics-server/381629>\
**Category:** Elastic Observability\
**Created:** [September 5, 2025, 8:55am UTC](https://discuss.elastic.co/t/pdf-screenshot-issue-different-behavior-local-vs-elastic-synthetics-server/381629 "2025-09-05T08:55:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jens\_strumper](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jens_strumper/32/144916_2.png) [@jens\_strumper](https://discuss.elastic.co/u/jens_strumper)\
**Post date:** [September 5, 2025, 8:55am UTC](https://discuss.elastic.co/t/pdf-screenshot-issue-different-behavior-local-vs-elastic-synthetics-server/381629/1 "2025-09-05T08:55:39Z")

</div>

**Problem**

I have a journey that needs to take a screenshot of a PDF document. The same code works perfectly locally but fails on the Elastic Synthetics server due to different tab/navigation behavior.

**Environment**

- Elastic Synthetics: Latest version
- Browser: Chromium (headless on server)
- Local testing: Using @elastic/synthetics package locally
- PDF URL structure: `api.example.com/v1/invoice/inline/document.pdf`

**Code Example**

```auto
step('Open PDF invoice', async () => {
  const invoiceLink = page.getByRole('link', { name: 'INVOICE-123' });
  await invoiceLink.waitFor({ state: 'visible' });
  
  // Remove target attribute to force same tab opening
  await invoiceLink.evaluate(node => node.removeAttribute('target'));
  
  // Click the invoice link
  await invoiceLink.click();
  await page.waitForTimeout(5000);
  
  const currentUrl = page.url();
  console.log('URL after click:', currentUrl);
  
  expect(currentUrl).toContain('.pdf'); // Fails on server
});

```

**Behavior Differences**

**Local Execution (works):**

- PDF opens in same tab
- URL becomes the PDF document URL
- PDF is visible in browser when running with --no-headless
- Test passes

**Elastic Synthetics Server (fails):**

- Despite removeAttribute('target'), PDF does not open in same tab
- Remains on the original overview page
- Screenshot shows the invoice list instead of PDF
- Test fails with expect().toContain('.pdf')

**Failed Attempts**

1. waitForNavigation: page.waitForNavigation() causes ERR\_ABORTED; frame was detached
2. Direct navigation: page.goto(pdfUrl) causes ERR\_ABORTED
3. New tab handling: context.waitForEvent('page') - new tab had empty URL `":"`
4. Different wait strategies: load, networkidle, etc. - same issues

**Question**

How can I reliably capture PDF screenshots in Elastic Synthetics when PDFs open in new tabs on the server but same tab locally?

Is there a recommended approach for PDF monitoring in Elastic Synthetics? The goal is to verify that invoices are accessible and take a screenshot for monitoring purposes.
