Web Browser (Legacy) - Extract table

Declaration

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

Related Topics    

Description

Extracts the contents of a given table in an established session and places the results in a dataset. The HTML element you specify must be a table, otherwise, an error is generated. This activity supports extraction of tabular data. Any HTML in the table’s cells will be stripped. To retrieve or set other elements such as an image or hyperlink, use other Web Browser (Legacy) activities such as Get value or Set Value.

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 (Legacy) 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 Web Browser (Legacy) Create session or Open activity. Numerous sessions are supported within a single task, however, since Web Browser (Legacy) actions 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 extract data from a web browser table. The data can be called in subsequent steps using the Loop Dataset activity.

Parameters

Location

Property Type Required Default Markup Description
Session name Text Yes BrowserLegacySession1 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.
Select browser --- --- --- --- This activity comprises Automate's Window Dissection technology to facilitate the discovery of existing windows and their controls. To select the target browser window, make certain the window is open and in the foreground (in front of all other open windows). Click and drag the magnifier icon, and then drop it over the window. If the window is supported by this activity, a green border will appear around it. Upon release, the Browser and URL parameters are populated with appropriate values. Alternatively, you can manually select a browser, enter the desired URL, and then click Open to test.
Browser Text(options) Yes Internet Explorer BROWSER="Firefox" The following browsers are supported with this activity:
  • Internet Explorer
  • Firefox
URL Text Yes (Empty) URL="www.google.com" The URL that this activity should be performed on (for example, www.helpsystems.com or https://www.helpsystems.com).
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 (in this case, the button to click), ensure the desired URL has been entered in the URL text box, and then click Open. The hand icon will now become enabled. Click and drag the hand icon, and then drop it over the desired control in the browser window. If the control is supported by this activity, a blue border will appear around it. Specific parameters become enabled depending on which elements 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 dependent 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 (for example, "/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 (certain elements) 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 (case-sensitive, all must match) --- --- --- --- 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. This parameter is disabled by default.
Attribute name Text No (Empty) HTMLATTRIBUTE NAME="foo" VALUE="bar" The name of the attribute to search for. Click Add to enter a new attribute name / value pair. To remove an existing name / value pair, highlight the proper row of data, and then click Remove.  
Attribute value Text No (Empty) HTMLATTRIBUTE NAME="foo" VALUE="bar" The name of the attribute to search for. Click Add to enter a new attribute name / value pair. To remove an existing name / value pair, highlight the proper row of data, and then click Remove.  
Locate by content (not recommended, slow) Text No (Empty) HTMLCONTENTS="contents" If enabled, specifies any actual 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 exceedingly slow. Use 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 five 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
Create and populate dataset Text Yes (Empty) RESULTDATASET="myDataset" The name of the dataset in which to populate with extracted table contents. Datasets are accessed in the same way that one would access information in a table, by specifying the column and row where the data resides. Every dataset created and used in Automate must have a unique name, much like variables. But because datasets are more like tables, the unique name of the dataset must be referenced followed by the column name/number enclosed in percentage signs (for example, %DatasetName.ColumnNumber%). When a dataset is created, the current row is automatically set to 1. To access other rows, use the Loop Dataset activity.

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.
  • Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.

Description

This sample task opens a w3school.com site and extracts contents from a sample HTML table onto a dataset. The dataset is then looped. During each iteration, the value of each column for a given row (starting row 2) is displayed in a message dialog. The last step closes the web browser, thus, ending the session and completing the task.

Copy
<AMVARIABLE NAME="rowNumber" VALUE="2" />
<AMBROWSER URL="http://www.w3schools.com/html/html_tables.asp" SESSION="mySession" />
<AMBROWSER ACTIVITY="extable" HTMLID="customers" SESSION="mySession" RESULTDATASET="content" />
<AMLOOP ACTIVITY="dataset" DATASET="content" />
<AMSHOWDIALOG>Value of row %rowNumber%,column 1: %content.column1%Value of row %rowNumber%,column 2: %content.column2%Value of row %rowNumber%,column 3: %content.column3%</AMSHOWDIALOG>
<AMVARIABLE ACTIVITY="increment" RESULTVARIABLE="rowNumber" />
<AMLOOP ACTIVITY="end" />
<AMBROWSER ACTIVITY="close" SESSION="mySession" />