The renewal maintenance has officially ended for Progress iMacros effective November 30, 2023.
This Wiki site will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely, The Progress Team
TAG parameters explained
Here's how the iMacro TAGs do correspond to the automated site's HTML code.
Background Information
HTML tags
An HTML page is built of text surrounded by tags. A link e.g. looks like this:
<a href="mydomain.com">This is my domain</a>
As you already see in this example, the tag has two constituents:
- the type
- <a> for a link (like in the example above)
- <table> for a table
- <td> for a table's field
- ...
- the type's attributes that refer to special features of the type
- "href=..." (for type <a>) gives the URL the link goes to)
- "border=..." (for <table>) gives the table's border's thickness
- "bgcolor=..." (for <td>) gives the field's background color
- ...
For more information on HTML tags and their attributes, there are very many internet resources, like this, this and this.
The formal specification (including a complete list of tags and attributes) for HTML 4.01 is given on the W3C site.
iMacros TAG commands
The TYPE and ATTR parameters
The main aim of iMacros TAG commands is to identify a certain HTML tag (which are then clicked, extracted, being filled in, etc...). In order to do so, the TAG command refers to the HTML tag's constituents, the type and the attribute.
Here's an example TAG command:
TAG POS=1 TYPE=A ATTR=HREF:mydomain.com
Which would make the macro select (follow) the HTML link we used above:
<a href="mydomain.com">This is my domain</a>
Note that the changes from HTML tag to TAG command are very small:
- types and attributes names are given in capital letters
- attributes' values are referred to by ":" and not by "=" (tag: "href=mydomain.com", ATTR: "HREF:mydomain.com)
The TXT parameter
The text which is enclosed by the HTML tag can be used in the TAG command, too (with blank spaces being replaced by "<SP>"):
TAG POS=1 TYPE=A ATTR=TXT:This<SP>is<SP>my<SP>domain
Multiple ATTR parameters
If an HTML tag uses more than one attribute, the TAG can refer to each of them, and to combinations.
Let's say, a table's field is given as
The field's text
Then, the TAG might refer to each of "width" and "nowrap" and the text "The field's text", or to more than one of them by connecting the attributes with "&&" (the sequence they are give in the TAG command does not need to match the sequence in the HTML tag):
TAG POS=1 TYPE=TD ATTR=WIDTH:22%&&NOWRAP:nowrap&&TXT:The<SP>field's<SP>text
Using multiple attributes is necessary if two or more HTML tags share some attributes like e.g.
Field 1 Field 2
In this example, making use of the BGCOLOR and TXT attributes would be needed to identify either of these fields correctly.
The POS parameter
Absolute positioning
If two HTML tags share all of their attributes, the TAG command's POS parameter can be used to determine which of the matching HTML tags is to be selected:
TAG POS=2 TYPE=TD ATTR=WIDTH:22%&&NOWRAP:nowrap&&TXT:The<SP>field's<SP>text
would select the second HTML tag on that page that looks like
The field's text
Relative positioning
While absolute positions (like POS=1, POS=2, ...) "start counting" from the beginning of the page, relative positions (like POS=R1, POS=R2, ...) search for matching HTML tags starting from the element that the last successful TAG referred to.
The folllwing macro would thus select the table's field, and then follow the next link to "mydomain" that comes after that table's field (e.g. in the next field)
TAG POS=1 TYPE=TD ATTR=WIDTH:22%&&NOWRAP:nowrap&&TXT:The<SP>field's<SP>text TAG POS=R1 TYPE=A ATTR=HREF:mydomain.com
You can also use relative positioning for (relative positioned) data extraction.
The FORM and CONTENT parameters
When automating forms, there are two more parameters at hand: FORM and CONTENT.
FORM works just like ATTR, and is used to identify the form that the element (checkbox, dropdown, ...) belongs to
If the HTML tag of that form looks like this
<form action="confirm.asp" method="post" name="TestForm" id="TestForm"> What do you want to eat ? <select size="1" name="main"> <option selected="selected">--- Please select ---</option> <option>Pizza</option> <option>French Fries</option> <option>Bread & Butter</option> </select> </form>
the form can be identified by (one or more of) its attributes
FORM=NAME:TestForm&&ACTION:confirm.asp&&METHOD:post
the page element in the form, is identified by TYPE and ATTR. With TYPE telling the macro about what to do with that form element e.g. do a selection, fill in text.
CONTENT, now , refers to the form's element intended change (input text, select drop-down, check radiobutton, ...). In the example above, it would e.g. read:
CONTENT=1
in order to select the first element of the drop-down.
The full TAG then looks e.g. like this:
TAG POS=1 TYPE=SELECT FORM=NAME:TestForm ATTR=NAME:main CONTENT=1
Examples
Note that we used HTML click mode on some of these examples to make the TAG commands show more attributes.
Select image
HTML code of element
<img border="0" src="bee.jpg" width="90" height="90" />
corresponding macro TAG command
TAG POS=1 TYPE=IMG ATTR=HREF:http://demo.imacros.net/Content/images/bee.jpg
Select table's cell
HTML code of element
CAD
corresponding macro TAG command
TAG POS=1 TYPE=TD ATTR=CLASS:bdytxt&&TXT:CAD
Check checkbox in form
HTML code of element
<form action="confirm.asp" method="post" name="TestForm" id="TestForm"> <input type="checkbox" name="C7" value="ON" /> Small <input type="checkbox" name="C8" value="ON" /> Medium <input type="checkbox" name="C9" value="ON" /> Large </form>
corresponding macro TAG command (checking checkbox "Large")
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:TestForm ATTR=NAME:C9&&VALUE:ON CONTENT=YES
Play with TAGs on our test page
There is an iMacros TAG test page, wich presents HTML elements, shows their source code and possible TAGs.
Use it as a playground for recording, manually changing and testing TAG commands.