Create new browser context for synthetics journey

Is there any way I can clear the browser context for a synthetic journey?

I'm configuring an Elastic Synthetics journey as a project. When I push the project to Elastic Synthetics, it runs as expected. When I run it locally, something in the context causes it to fail. It appears that the browser is picking up some sort of authentication from my environment.

Is there any way I can force Synthetics to clear the browser? I know if I were doing this directly with Playwright, I could manage it, but can I do something similar with @elastic/synthetics?

Hi @DougR

Apologies for the delay in responding. There is a single context created for each run locally and that is shared across all journeys which might explain the issue you are seeing. You could try clearing the cookies via context.clearCookies()

journey('test journey', ({ browser, context, page }) => {
  // fresh incognito context
  const ctx = browser.newContext();

One caveat of new context is that you might loose the functionality of Network request tracing etc we only capture the traces related to provided context.

If clearing doesnt help, let us know we will look in to creating a unique context per journey as it might be better than sharing it across all journeys and would match with what we are doing on our Global infra.


I'm not at all sure how I missed your reply to this, but I've tried your various solutions and neither works.

I would suggest that creating a unique context per journey would be a better solution anyway, so that the development environment mirrors the actual test environment as closely as possible.