Skip to main content

Step for obtaining the current page URL

It would be nice to have an easy way to find/save the current webpage url to a variable without resorting to custom javascrip step.

I looked into the Built-in variables section of my project but couldn’t find something similar.

Not sure what a decent solution would be here. A built-in variable might not be the best, because the “current webpage” url is not always the same, but can change constantly.


Maybe a new Action item for the “WINDOW” section?

To give you more context into my scenario and why the assert URL address is not what I need:

  • I go to a webpage

    https://platform.co/product

  • I create a new entity inside the webpage, for example a new product

  • The url changes → it now ends in /product-123456, so it there’s now a uniquely generated id

  • I want to save the entire url in a variable so I can use it later in the test, so {{product_url}}= “https://platform.co/product-123456”

  • I have no way in the platform to get the product id besides from the URL

In scenario above, ideally I would like to save the current webpage url in a variable after creating the product, and then use the “Go to URL” step to navigate to value of the variable.

Status: Completed4 comments

Log in to comment and vote

Comments4

  • Paweł Bylina changed status to Completed
    Team•

    Nov 25, 2025

    Pinned

    We’ve added built-in variables currentUrl and currentPathname:

  • Benjy Wang

    •

    Mar 3, 2025

    You could use the run javascript step with something like this..

    const currentURL = window.location.href;
    console.log(currentURL);

    But I’m not sure how to save that as a variable in BugBug.io

    • Paweł Bylina

      Team•

      Mar 7, 2025

      You can use “Set variable”

  • Paweł Bylina

    Team•

    Jan 29, 2025

    Thanks, good idea!