Web Browser - Get URL
Declaration
<AMWEBBROWSER ACTIVITY="get_url" SESSION="text" RESULTVARIABLE="text" />
Description
Retrieves the session's active URL and populates a variable with the result.
NOTE:
- The Web Browser action is not backwards compatible with the Web Browser (Legacy) action.
- Automation with the Web Browser action is only compatible with Internet Explorer, Chrome, Edge, and Firefox browsers.
- You must update the specified browser to the latest version and install it on the target system to ensure the Web Browser action functions correctly.
- Unlike other session-based actions where sessions are optional, the Web Browser action requires the use of a session as each created session explicitly links to a specific web browser instance (you can create a session using the Web Browser - Create session or Web Browser - Open activity). A single task can support numerous sessions; however, since Web Browser activities are performed interactively (and not in the background), each session must run concurrently to avoid sending interactions to the wrong browser window.
Practical usage
Used to retrieve a URL from an active session.
Parameters
Browser
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Session name | Text | Yes | BrowserSession1 | SESSION="mySession" | The existing session to use with this activity. Numerous
sessions can exist within a single task which allows several web browser
operations to be performed simultaneously on separate browser
windows. NOTE: Sessions are supported in Internet Explorer, Chrome, Edge, and Firefox browsers
only. Firefox does not require a separate extension to be installed with this version of the Web Browser action. |
Place session's active URL in variable | Text | Yes | (Empty) | RESULTVARIABLE="theURL" | Retrieves and stores the session's active URL. |
Example
NOTE:
- Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
- To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.
Description
A simple task that populates a session's active URL into a variable, which is then displayed in a message dialog. Then, the task closes the web browser which ends the session.
Copy
<AMVARIABLE NAME="theURL" VALUE="" />
<AMWEBBROWSER URL="https://www.google.com" BROWSER="firefox" SESSION="BrowserSession1" />
<AMWEBBROWSER ACTIVITY="get_url" SESSION="BrowserSession1" RESULTVARIABLE="theURL" />
<AMSHOWDIALOG WINDOWTITLE="The Active Session's current URL">URL = %theURL%</AMSHOWDIALOG>
<AMWEBBROWSER ACTIVITY="close" SESSION="BrowserSession1" />