How to reference cookie session id in task?

Here is my scenario.

Task 1 - Authenticate to a website (success)

      I see my session id in my Data->Cookies

Task 2 - Go to New URL with session id (fail)

      http://reports.site.com/hrreports.aspx?s=${SESSION_ID}&Version=25.07&MinorVersion=1.00&AppVersion=ENT

How do I accomplish this? I tried use javascript but got a ‘await is not available at this level’ type error.

Welcome to the community!

Can you share the site details or the specific URL you are working with?

Based on your description, this is likely an issue with the site itself rather than your task setup. Some sites require specific headers or secondary cookies to be passed alongside the session ID for a URL like that to validate.

Once we have the site details, we can check if there are additional parameters needed to make the request successful. In the meantime, try restarting your container to ensure you’re working with a fresh session. If the issue persists after that, I’ll help you troubleshoot further.

The problem I am trying to solve is how to change focus to a popup window. The URL of the popup is accessible and easily computable, I just have to add the session-id to the URL. So how can I add the session-id to a URL or how do I change focus to a popup?

Since Doppelganger is built on Playwright, it handles windows as ‘pages.’ You can use a JavaScript block to wait for the popup and switch focus to it. Because the tool uses persistent state, the popup will already be logged in—you don’t need to manually append the ${SESSION_ID} to the URL.

By using the popup object in your script, you are effectively ‘focusing’ on it without needing a dedicated ‘switch’ command."

1 Like
Running custom JavaScript...
›
FAILED action javascript: page.evaluate: SyntaxError: await is only valid in async functions and the top level bodies of modules at eval (eval at evaluate (:290:30), <anonymous>:3:45) at UtilityScript.evaluate (<anonymous>:292:16) at UtilityScript.<anonymous> (<anonymous>:1:44)

Can you share a quick javascript block that would work? Not looking for much js script here but I cannot any js to run at all.

await page.goto('https://www.google.com');

Hey, just ask any LLM to generate it for you. Trial and error is the way to go—give it the details you have, because I don’t have specifics about what you’re doing.

For example, you can ask it to generate a Playwright script (which Doppelganger JS blocks support). Also, don’t put await inside page.evaluate(), that’s what causes:

SyntaxError: await is only valid in async functions and the top level bodies of modules

A quick working approach is:

(async () => {
  await page.goto('https://www.google.com');
  const title = await page.title();
  console.log('Page title:', title);
})();

So basically, tell the LLM what you want it to do. Let it generate the JS block for you.

Here is the result of the your example.

FAILED action javascript: page.evaluate: ReferenceError: page is not defined at eval (eval at (eval at evaluate (:290:30)), :2:3) at eval (eval at (eval at evaluate (:290:30)), :5:3) at eval (eval at evaluate (:290:30), :3:40) at UtilityScript.evaluate (:292:16) at UtilityScript. (:1:44)

That error means your JavaScript action runs inside the page context, not Node/Playwright. So page doesn’t exist there.

In your “JavaScript” action, remove page usage and just do page‑context code, e.g.:

const title = document.title;
return `Page title: ${title}