Web Browser - Get value

Declaration

<AMBROWSER ACTIVITY="getvalue" PATH="text" HTMLID="text" HTMLNAME="text" HTMLTAG="text" HTMLCONTENTS="text" USEMATCH="text" SESSION="text" RESULTDATASET="text" ATTRIBUTE="text"><HTMLATTRIBUTE NAME="text" VALUE="text" /></AMBROWSER>

Related Topics    

Description

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

NOTE: The following are important notes to consider

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 simulate the process of manually copying the value displayed in a text-box or control for the purpose of pasting it onto another program, application or web browser window.

Parameters

Location

This activity comprises AutoMate's Window Dissection technology to facilitate the discovery of existing windows and their controls. To select the target browser window:

  1. Make certain the window is open and in the foreground (in front of all other open windows).
  2. Drag and release the magnifier icon over the window. If the window is supported by this activity, a green border will appear around it.
  3. Upon release, the Browser and URL parameters are populated with appropriate values. Alternatively, you can manually select a browser and enter a URL in the provided text-box, then click Open to test.

Property

Type

Required

Default

Markup

Description

Session

Text

Yes

BrowserSession1

SESSION="mySession"

The name of an existing session to attach this activity to. Numerous sessions can exist within a single task allowing several web browser operations to be performed simultaneously on separate browser windows.

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 required to identify the object that this activity should be performed on. To pinpoint an HTML element, click and hold down the hand 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. Using an element's unique ID as a search method is considered the fastest and most accurate method of locating an HTML element because an element ID is always unique within an 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/inner_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)

HtmlAttribute Name="foo" Value="bar"

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)

HtmlAttribute Name="foo" Value="bar"

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. Use this method as a last resort if all other methods cannot be used.

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

Property

Type

Required

Default

Markup

Description

Copy

Text

(options)

No

Text

  1. ATTRIBUTE=":text"

  2. ATTRIBUTE=":html"

  3. ATTRIBUTE="custom"

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>)

  • 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

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 creates a variable named "myVar" and opens an IE browser window set to the web page http://www.google.com. A Get value activity is then performed to retrieve the value of the I'm Feeling Lucky button and populates the "myVar" variable with results. Finally, a Close browser step closes the browser window and ends the session.

<AMVARIABLE NAME="myVar" />

<AMBROWSER URL="http://www.google.com/" and creates a session named "BrowserSession2" />

<AMBROWSER ACTIVITY="getvalue" HTMLNAME="btnI" SESSION="BrowserSession2" RESULTVARIABLE="myVar" ATTRIBUTE=":text" />

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