Web Browser - Set value

Declaration

<AMBROWSER ACTIVITY="setvalue" PATH="text" HTMLID="text" HTMLNAME="text" HTMLTAG="text" HTMLCONTENTS="text" USEMATCH="text" SESSION="text" VALUE="text" ATTRIBUTE="text (options)"><HTMLATTRIBUTE NAME="text" VALUE="text" /></AMBROWSER>

Related Topics    

Description

Sets the specified value onto an element in an established web browser session.

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

Commonly used to inject a value into a specific object or control in a browser.

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 the desired URL, 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

Set

Text (options)

No

Text

  1. ATTRIBUTE=":text"

  2. ATTRIBUTE=":html"

  3. ATTRIBUTE="custom"

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

  • Text - Set text.

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

  • Specific attribute - Set a specific attribute. You can use any desired attribute, however, some common attributes are listed as follows:

ID | Name | Value | Type | Checked

Change to

Text

Yes

(Empty)

VALUE="Network Automation"

The value that should be set.

Disguise the value

---

---

---

---

If enabled, the value will appear encrypted in the AML code. If disabled, the value will appear in plain text. This is a visual parameter only used during design-time, therefore, contains on markups.

For multiple matches, set attribute of all matching controls

Yes/No

No

No

MULTIPLE="YES"

If set to YES specifies that change will be performed on all matches. No errors are raised for zero matches. If set to NO, specifies that there should be only one match. If zero or more than one matching controls are found, an error will occur. This parameter is set to NO by default.

 

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 simple task opens a browser set to the URL https://www.google.com/sets the value "Network Automation" in the search box and sends the keystroke ENTER.

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

<AMBROWSER ACTIVITY="setvalue" HTMLNAME="q" SESSION="BrowserSession2" VALUE="Network Automation" ATTRIBUTE=":text" />

<AMINPUT KEYSTROKES="{ENTER}" STAYFOCUSED="YES" />