Skip to main content
The get_url method retrieves the URL of the currently active page in the browser window. This is useful for verifying navigation, capturing the current state, or building conditional logic based on the page location.

Method Signature

async def get_url(
    self,
    *,
    timeout: int | None = None,
) -> GetUrlResponse

Parameters

timeout
int | None
default:"None"
Optional timeout in milliseconds. If not specified, uses the default timeout.

Return Value

Returns a GetUrlResponse object:
url
str
The URL of the currently active page.

Example

import asyncio
from narada import Narada

async def main():
    async with Narada() as narada:
        window = await narada.open_and_initialize_browser_window()

        # Navigate to a page
        await window.go_to_url(url="https://www.google.com", new_tab=True)

        # Get the current URL
        response = await window.get_url()
        print(f"Current URL: {response.url}")
        # Output: Current URL: https://www.google.com/

        # Use in conditional logic
        await window.agent(prompt="Search for Narada AI")

        response = await window.get_url()
        if "search" in response.url:
            print("Search results page loaded successfully")

if __name__ == "__main__":
    asyncio.run(main())

Use Cases

Verify Navigation

Confirm the browser navigated to the expected page after an action

Conditional Logic

Branch your automation based on the current page URL

Logging & Debugging

Log the current URL at each step for debugging automation flows

URL Extraction

Capture the final URL after redirects or form submissions