# How bypass a login popup in Synthetics?

**URL:** https://discuss.elastic.co/t/how-bypass-a-login-popup-in-synthetics/356796
**Category:** Synthetics
**Created:** [April 4, 2024, 3:35pm UTC](https://discuss.elastic.co/t/how-bypass-a-login-popup-in-synthetics/356796 "2024-04-04T15:35:10Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![rafaeljsc](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@rafaeljsc](https://discuss.elastic.co/u/rafaeljsc)
#### Post date: [April 4, 2024, 3:35pm UTC](https://discuss.elastic.co/t/how-bypass-a-login-popup-in-synthetics/356796/1 "2024-04-04T15:35:10Z")

</div>

I'm building a synthetic monitoring where I need login in this page to enter on the application:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/a/da5537f89a5706090d417d8ffa782bed34d51f5a.png)

But I can't interact with this pop up, because it is not page's part, it is a browser part.

So, I set a header to bypass it:

```auto
step("1- App Logon", async () => {

    const headers = {
      "Authorization": "Basic " + btoa(`${params.login}:${params.password}`),
    };

    page.setExtraHTTPHeaders(headers)
    await page.goto(params.url_orthanc, {waitUntil: 'domcontentloaded'}); 
    await page.locator('text=Welcome!').first().focus()
  });

```

this worked fine! but only in my pc 🥲

when I push it to Synthetics, I received a timeout error on this step.

I'm in same network's Synthetics.

Could You help me??

---

<div class="post-metadata">

### Author: ![emilioalvap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emilioalvap/32/99310_2.png) [@emilioalvap](https://discuss.elastic.co/u/emilioalvap)
#### Post date: [April 9, 2024, 9:40am UTC](https://discuss.elastic.co/t/how-bypass-a-login-popup-in-synthetics/356796/2 "2024-04-09T09:40:38Z")

</div>

Hi @rafaeljsc,

Thanks for your interest in Synthetics!  
When you mention that it's not working remotely, is this monitor running in a [private location](https://www.elastic.co/guide/en/observability/current/synthetics-private-location.html#monitor-via-private-agent) or in one our [publicly hosted locations](https://github.com/elastic/synthetics/blob/v1.3.0/src/locations/public-locations.ts#L28-L37)? If it's latter, I'd recommend opening a support request through Elastic Cloud portal so that we can more easily debug the problem.

---

<div class="post-metadata">

### Author: ![rafaeljsc](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@rafaeljsc](https://discuss.elastic.co/u/rafaeljsc)
#### Post date: [April 15, 2024, 9:09pm UTC](https://discuss.elastic.co/t/how-bypass-a-login-popup-in-synthetics/356796/3 "2024-04-15T21:09:30Z")

</div>

Hi @emilioalvap !

the issue happens in a private location. How can I solve it in this instance?

---

<div class="post-metadata">

### Author: ![emilioalvap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emilioalvap/32/99310_2.png) [@emilioalvap](https://discuss.elastic.co/u/emilioalvap)
#### Post date: [April 16, 2024, 11:02am UTC](https://discuss.elastic.co/t/how-bypass-a-login-popup-in-synthetics/356796/4 "2024-04-16T11:02:38Z")

</div>

Hi @rafaeljsc,

String interpolation is not currently supported on scripted monitors as it interferes with the generated policy, I'd suggest replacing them with string concatenation and testing again:

```auto
step("1- App Logon", async () => {

    const headers = {
      "Authorization": "Basic " + btoa(params.login + ":" + params.password),
    };

    page.setExtraHTTPHeaders(headers)
    await page.goto(params.url_orthanc, {waitUntil: 'domcontentloaded'}); 
    await page.locator('text=Welcome!').first().focus()
  });

```

---

<div class="post-metadata">

### Author: ![rafaeljsc](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@rafaeljsc](https://discuss.elastic.co/u/rafaeljsc)
#### Post date: [April 16, 2024, 6:04pm UTC](https://discuss.elastic.co/t/how-bypass-a-login-popup-in-synthetics/356796/5 "2024-04-16T18:04:31Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/3/f/3fb8d53086e7894f7cbfba8d58d49e62f98b2f60.png)

same result...

I tried authenticate without a header too with this model:

`https://username:password@hvv.pacs.rededor.com.br`

And the same error happens: succeeded on my pc, but timeout on Synthetics.

If I pass only URL, without headers or parameters, I get an error 401: Unauthorized.

```auto
page.goto: net::ERR_INVALID_AUTH_CREDENTIALS at https://hvv.pacs.rededor.com.br/
   Call log:
     - navigating to "https://hvv.pacs.rededor.com.br/", waiting until "domcontentloaded"

```

---

<div class="post-metadata">

### Author: ![emilioalvap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emilioalvap/32/99310_2.png) [@emilioalvap](https://discuss.elastic.co/u/emilioalvap)
#### Post date: [April 17, 2024, 9:08am UTC](https://discuss.elastic.co/t/how-bypass-a-login-popup-in-synthetics/356796/6 "2024-04-17T09:08:06Z")

</div>

Hi @rafaeljsc,

Do you ever get 401 Unauthorized from the monitor running in the private location? If that's not the case, can you test that it has network access to the endpoint (by issuing curl/wget)? Once network access has been discarded, we can look into more details.
