Web Browser - Extract Source

Declaration

<AMBROWSER ACTIVITY="exsource" SESSION="text" RESULTVARIABLE="text" />

Related Topics    

Description

Extracts an HTML source and places the result in a variable.

NOTE: Automation can be performed on Internet Explorer and Firefox browsers only. Firefox automation requires a separate extension which can be downloaded from here. The browser you specify must be installed on the target system to ensure that these activities function properly. Unlike other session-based actions in which sessions are optional, the use of a session in the Web Browser action is required due to the fact that each created session explicitly links to a specific web browser instance. A session can be created using the Create session or Open Web Browser activity. Numerous sessions are supported within a single task, however, since Web Browser actions are performed interactively (and not in the background), each session must run concurrently and not simultaneously in order to avoid sending interactions to the wrong browser window.

Practical Usage

Used to retrieve the HTML source, which is the web page's raw programming code. You can normally view the source by right clicking on a page and choosing View source.

Parameters

Browser

Property

Type

Required

Default

Markup

Description

Session name

Text

Yes

BrowserSession1

SESSION="mySession"

Specifies the name of an existing session to associate with this activity. Numerous sessions can exist within a single task allowing activities to be performed on several web browsers simultaneously. If working with only one browser, this can remain at the default session name, which is BrowserSession1.

NOTE: Sessions are supported in Internet Explorer and Firefox browsers only.

Store HTML source in

Text

Yes

(Empty)

RESULTVARIABLE="myVar"

The name of an existing variable in which to populate the  HTML source with.

 

Description

Error Causes

On Error

Example

NOTE: The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

Description

This task extracts the source of www.networkautomation.com and displays it in a message dialog.

<AMVARIABLE NAME="theSource" />

<AMBROWSER URL="http://www.networkautomation.com/" SESSION="BrowserSession1" />

<AMBROWSER ACTIVITY="exsource" SESSION="BrowserSession1" RESULTVARIABLE="theSource" />

<AMSHOWDIALOG>%theSource%</AMSHOWDIALOG>