Web Browser - Extract table

Declaration

<AMBROWSER ACTIVITY="extable" PATH="text" HTMLID="text" HTMLNAME="text" HTMLTAG="text" HTMLCONTENTS="text" USEMATCH="text" 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 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 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 extract data from a web browser table. The data can be called in subsequent steps using the Loop dataset activity.

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 (in this case, a valid HTML table) click and hold down the hand icon and 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 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

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 (i.e. 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.

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.

<AMVARIABLE NAME="rowNumber" VALUE="2" />

<AMBROWSER URL="http://www.w3schools.com/html/html_tables.asp" SESSION="BrowserSession1" />

<AMBROWSER ACTIVITY="extable" HTMLTAG="TABLE" SESSION="BrowserSession1" RESULTDATASET="content"><HTMLATTRIBUTE NAME="className" VALUE="reference" /></AMBROWSER>

<AMLOOP ACTIVITY="dataset" DATASET="content" FROM="2">

   <AMSHOWDIALOG WINDOWTITLE="Current Value">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>

<AMBROWSER ACTIVITY="close" SESSION="BrowserSession1" />