Web Browser - Get Value

Declaration

<AMBROWSER ACTIVITY="getvalue" SESSION="text" ATTRIBUTE=":html" RESULTDATASET="text" PATH="text" HTMLTAG="text" HTMLID="text" HTMLNAME="text" USEMATCH="text" HTMLCONTENTS="text"><HtmlAttribute Name="text" Value="text" /><HtmlAttribute Name="text" Value="text" /></AMBROWSER>

See Also

Web Browser - Browser State, Web Browser - Close, Web Browser - Extract Table, Web Browser - Get Value, Web Browser - Set Value

Description

Gets the value of a given element in an established web browser session and places the results in a variable or dataset.

IMPORTANT: AutoMate supports Internet Explorer automation out-of-the-box; Firefox automation requires a separate extension, which can be downloaded from here. Additionally, the browser you specify must be installed on the target system to ensure that these activities function properly.

Practical Usage

Used to extract an element's value onto a variable or dataset.

Parameters

Location Properties

Property

Type

Required

Default

Markup

Description

Session

Text

No

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.

Select Browser

The following parameters specify information about the browser and URL in which to perform this activity. To capture an open browser window, click and hold down the Drag icon and drop it over the desired window. Alternatively, you can click the drop-down arrow to select from a list of recently opened URLs or manually enter the desired URL in the provided text box. Thereafter, click the Open button.

Browser

Text

 (options)

No

Internet Explorer

BROWSER="Firefox"

The web browser in which this activity should be performed. The available options are:

  • Internet Explorer - This activity should be performed on an Internet Explorer browser.

  • Firefox - This activity should be performed on Firefox browser.

URL

Text

Yes

(Empty)

URL="www.google.com"

The URL (Uniform Resource Locator) that this activity should be performed on.

Locate HTML elements

The following parameters relate to the specification of HTML elements needed to identify the object that this activity should be performed on. To pinpoint an HTML element, click and hold down the Drag icon and drop it over the desired control in the  browser window. Specific parameters become enabled depending on which element(s) were detected as a result of the drag and drop operation. You can further fine tune your selection by editing these parameters.

NOTE: The overall speed and accuracy of an element search is highly dependant on the amount of contents an HTML document contains as well as the type of criteria being used to search for the element. For example,  using an element's unique ID as a search method is considered the fastest and most accurate method of locating an HTML element due to the fact that an element ID is unique within the HTML document.

Path within the document hierarchy

Text

No

(Empty)

PATH="/outer/inner/"

If the desired control is located within a floating frame, you can specify a frame hierarchy in this field. The specifier is a list of slash delimited frame identifiers (i.e. "/outer_frame/inne_framer/").

Locate by identifier (best method)

Text

No

(Empty)

HTMLID="unique_ID"

If enabled, specifies that the unique ID identifying the target object will be searched. Specifying an element's unique identifier (where it is supported) is the fastest and most accurate method of locating an HTML element due to the fact that an ID must be unique within the HTML document. This parameter is disabled by default.

Locate by name

Text

No

(Empty)

HTMLNAME="element_name"

If enabled, specifies that the unique name identifying the target object will be searched. Specifying an element's unique name (where it is supported) is a fast and accurate method of locating an HTML element due to the fact that an element name must be unique within the HTML document. This parameter is disabled by default.

Locate by HTML tag

Text

No

(Empty)

HTMLTAG="tagName"

If enabled, specifies that the start tag (or opening tag) identifying the target object will be searched.

Locate by attributes

If enabled, allows attribute name/value pairs to be used as search criteria. Attributes provide additional information about HTML elements. If this option is enabled,the parameters specified below become active.

Attribute name

Text

No

(Empty)

NAME="attrib_name"

The name of the attribute to search for. Click the Add button to enter a new attribute name/value pair. To remove an existing name/value pair, highlight the proper row of data and click the Remove button.  

Attribute value

Text

No

(Empty)

VALUE="attrib_value"

The value of the attribute to search for. Click the Add button to enter a new attribute name/value pair. To remove an existing name/value pair, highlight the proper row of data and click the Remove button.  

Locate by content

Text

No

(Empty)

HTMLCONTENTS="contents"

If enabled, specifies that  any textual and graphical content between the start and end tags will be used as search criteria. This parameter is disabled by default.

NOTE: This search method is  not recommended because it can be exceedingly slow and imprecise.

Restrict to specific match

Number

No

(Empty)

USEMATCH="44"

If enabled, specifies which occurrence to use if there are multiple matches. For example, if 5 text boxes match and this parameter is set to 4, it will apply the activity to the fourth text box. This parameter is disabled by default.

 

Interaction Properties

Property

Type

Required

Default

Markup

Description

Copy

Text

(options)

No

 

ATTRIBUTE="id"

The type of value to copy. The available options are:

  • Text - Copy text.

  • Enclosed HTML - Copy HTML enclosed in the opening and closing HTML tag. (Example:  “foo” in <DIV >foo</DIV>)

  • HTML Tag - Copy an HTML tag.

  • Specific Attribute - Copy a specific attribute. You can use any desired attribute, however, some common attributes are listed for convenience. They are as follows:

ID | Name | Value | Type | Checked

Place a single match in variable

Text

No

(Empty)

RESUTLVARIABLE="myVar"

The name of an existing variable to populate with the individual match.

Place a number of matches in dataset

Text

No

(Empty)

RESULTDATASET="myDataset"

The name of the dataset in which to populate with all matches.

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties allows you to instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables and Functions

All text fields allow the use of expressions such as variables, functions or AutoMate extended functions, which can be entered by surrounding the expression in percentage signs (example: %FileDateTime(myVar)% or %myVar%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on function

More on extended functions
More on the expression builder

Example

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

 

Description: Create a variable named "myVar". Open URL "http://www.google.com/" using Internet Explorer. Get text and store the result in "myVar". Display the message "Value = %myVar%" in a message box.

 

<AMVARIABLE NAME="myVar"></AMVARIABLE>

<AMBROWSER URL="http://www.google.com/" SESSION="BrowserSession2" />

<AMBROWSER ACTIVITY="getvalue" SESSION="BrowserSession2" RESULTVARIABLE="myVar" HTMLNAME="btnG" USEMATCH="2" />

<AMSHOWDIALOG>Value = %myVar%</AMSHOWDIALOG>

 

↑ Top of Page