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
Difference between revisions of "Form Filling"
(54 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
+ | __TOC__ | ||
+ | |||
===Introduction=== | ===Introduction=== | ||
Are you tired of filling out the same form over and over again? Then let iMacros help you. Simply put all data to be input into a very straightforward and easily understandable text file and iMacros can read the data from there and submit it to the web site - completely automatic, without your interaction! | Are you tired of filling out the same form over and over again? Then let iMacros help you. Simply put all data to be input into a very straightforward and easily understandable text file and iMacros can read the data from there and submit it to the web site - completely automatic, without your interaction! | ||
− | + | Put your data in a comma separated text file (CSV format), which can be generated and edited by Microsoft Excel and many other applications, and iMacros will do the rest. | |
+ | |||
+ | More advanced users might connect directly to databases to retrieve the data. | ||
− | + | Related example macros: [[Demo-Datasource]], [[Demo-Loop-Csv-2-Web]] | |
− | + | Related example script: [[File-2-Web.vbs]], [[File-2-Web-Method2.vbs]], [[Database-2-Web.vbs]] | |
− | + | ==Variables [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]] [[Image:Cr-icon.png|Chrome]]== | |
− | + | Related example macros: [[Demo-Datasource]], [[Demo-Slideshow]] | |
− | + | Note: Not all iMacros editions support all variables as described below. Please refer to [[Features Comparison]] to see your iMacros edition's support of variables. | |
− | |||
Variables are, as the name suggests, constructs that allow you to dynamically, usually during runtime, hold different values. This is very helpful when you are trying to follow links that contain changing words or when you want to use the same macro for entering different values into a search engine. | Variables are, as the name suggests, constructs that allow you to dynamically, usually during runtime, hold different values. This is very helpful when you are trying to follow links that contain changing words or when you want to use the same macro for entering different values into a search engine. | ||
Line 27: | Line 30: | ||
There are two kinds of variables in iMacros: | There are two kinds of variables in iMacros: | ||
− | ===Built-in variables [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]]=== | + | ===Built-in variables [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]] [[Image:Cr-icon.png|Chrome]]=== |
These variables are used to define certain properties of the macro's behavior, for example the macro timeout value: | These variables are used to define certain properties of the macro's behavior, for example the macro timeout value: | ||
− | SET ! | + | SET !TIMEOUT_MACRO 300 |
− | There | + | There is a set of special built-in variables, !VAR1, !VAR2, ..., !VAR9, !VAR0, which can be set to anything you like. They are also defined with the SET command |
SET !VAR1 hello<SP>world | SET !VAR1 hello<SP>world | ||
Line 38: | Line 41: | ||
Alternatively, you can prompt the user to input a value: | Alternatively, you can prompt the user to input a value: | ||
− | PROMPT Please | + | PROMPT "Please enter text" !VAR1 |
− | ===User-defined Variables | + | ===User-defined Variables === |
− | These variables are created during runtime ("on the fly") | + | These variables are created during runtime ("on the fly"). There are 3 different ways of creating variables: |
+ | 1. You may use the command line switch -var_MYVAR like in | ||
imacros.exe -macro myMacro -var_ITEM 15 | imacros.exe -macro myMacro -var_ITEM 15 | ||
+ | which creates the variable ITEM during replay of the macro myMacro and gives it the value 15. | ||
− | + | 2. The second options is to use the iimSet function of the Scripting Interface. In a Visual Basic Script example this would look like: | |
− | + | iret = imacros.iimSet("ITEM", "15") | |
− | The second options is to use the iimSet function of the Scripting Interface. In a Visual Basic Script example this would look like: | ||
− | |||
− | iret = imacros.iimSet(" | ||
+ | 3. Or you may simply use the [[SET]] command as in | ||
+ | SET ITEM 15 | ||
− | Note that the user-defined variables ''' | + | Note that the user-defined variables '''should not have a prefixed "!"'''. Only the built-in ones do, like e.g. [[!LOOP]]. |
== Data Input == | == Data Input == | ||
Line 59: | Line 63: | ||
<small>[http://wiki.imacros.net/CSV_input Short URL to this section]</small> | <small>[http://wiki.imacros.net/CSV_input Short URL to this section]</small> | ||
− | + | Related examples: [[Demo-Loop-Csv-2-Web]], [[File-2-Web.vbs]] | |
− | |||
iMacros allows you to specify a text file with comma separated values ([[csv|CSV]]) to be used as input. Imagine, for example, that you want to submit a list of CD's to an online auction. Here is the list of the CD's in the comma separated format: | iMacros allows you to specify a text file with comma separated values ([[csv|CSV]]) to be used as input. Imagine, for example, that you want to submit a list of CD's to an online auction. Here is the list of the CD's in the comma separated format: | ||
Line 70: | Line 73: | ||
"Mozart", "Requiem", "7.50" | "Mozart", "Requiem", "7.50" | ||
− | Note: Quotation marks are optional in most cases. They are only required if the value itself contains a comma. | + | Note: Quotation marks are optional in most cases. They are only required if the value itself contains a comma, a quotation mark, or a new line. |
− | We now need to | + | We now need to write in the macro where the data input file can be found. For that we use the built-in variable !DATASOURCE |
SET !DATASOURCE OnlineAuction.csv | SET !DATASOURCE OnlineAuction.csv | ||
− | If you do not use any path information (like C:\myPath\) in the !DATASOURCE value the file is assumed to lie in the standard datasources directory, which can be specified in the Paths tab | + | If you do not use any path information (like C:\myPath\) in the !DATASOURCE value the file is assumed to lie in the standard datasources directory, which can be specified in the Paths tab in iMacros Settings. The default directory is in the datasources\ directory of your iMacros personal folder (e.g. C:\Users\Me\Documents\iMacros). |
− | |||
− | |||
− | + | <!--iMacros for Firefox and iMacros for Chrome need to know the number of columns in the CSV file, to read it properly. Set it using | |
− | + | SET !DATASOURCE_COLUMNS 8 | |
− | Since we want to insert all datasets into the form we need to loop over the macro, each time inserting the next CD. Therefore, we need to tell iMacros in which line of the datasource we currently are. We do this using the built-in variable !DATASOURCE_LINE. By cunningly using the built-in variable !LOOP we let iMacros take care of the counting: | + | for instance. In the iMacros Browser and iMacros for Internet Explorer this command has no effect. |
+ | --> | ||
+ | Since we want to insert all datasets into the form we need to loop over the macro, each time inserting the next CD. Therefore, we need to tell iMacros in which line of the datasource we currently are. We do this using the built-in variable !DATASOURCE_LINE. By cunningly using the built-in variable !LOOP we let iMacros take care of the counting. And since the first line is just the header, we would like to skip it and start counting from 2: | ||
+ | <nowiki> SET !LOOP 2</nowiki> | ||
<nowiki> SET !DATASOURCE_LINE {{!LOOP}}</nowiki> | <nowiki> SET !DATASOURCE_LINE {{!LOOP}}</nowiki> | ||
Now we can have the macro fill out the online form with the values from the current CD dataset. We use the built-in variables !COLn, where n represents the number of the columns to put into the form element. | Now we can have the macro fill out the online form with the values from the current CD dataset. We use the built-in variables !COLn, where n represents the number of the columns to put into the form element. | ||
− | <nowiki> TAG TYPE=INPUT:TEXT FORM=Listing ATTR=NAME:Name CONTENT={{!COL1}} | + | <nowiki> TAG TYPE=INPUT:TEXT FORM=Listing ATTR=NAME:Name CONTENT={{!COL1}}</nowiki> |
− | <nowiki> TAG TYPE=INPUT:TEXT FORM=Listing ATTR=NAME:Album CONTENT={{!COL2}} | + | <nowiki> TAG TYPE=INPUT:TEXT FORM=Listing ATTR=NAME:Album CONTENT={{!COL2}}</nowiki> |
<nowiki> TAG TYPE=INPUT:TEXT FORM=Listing ATTR=NAME:Price CONTENT={{!COL3}}</nowiki> | <nowiki> TAG TYPE=INPUT:TEXT FORM=Listing ATTR=NAME:Price CONTENT={{!COL3}}</nowiki> | ||
+ | [[Image:Play_Loop.png|right|thumb|Repeat macro playback]] | ||
− | During the execution of the macro the constants in | + | During the execution of the macro the constants in brackets <nowiki>{{..}}</nowiki> are replaced by the value specified in the data sources. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Set the maximum number of times to repeat the macro to number of the last line you want to reach in your CSV file, and press Play. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
===Input from Database === | ===Input from Database === | ||
− | + | Related example script: [[File-2-Web-Method2.vbs]], [[Database-2-Web.vbs]] | |
− | |||
− | |||
− | |||
− | iMacros can read data directly from any Windows database using the Scripting Interface and a few lines of code. | + | iMacros can read data directly from any Windows database using the Scripting Interface and a few lines of code. Not all editions of iMacros comes with the Scripting Interface, please refer to the [[Features Comparison]] page to see if your iMacros support this feature. |
− | This example code in Visual Basic Script connects to | + | This example code in Visual Basic Script connects to a Microsoft Access database: |
' open database | ' open database | ||
Line 179: | Line 128: | ||
do until rs.eof | do until rs.eof | ||
'Set the variable | 'Set the variable | ||
− | iret = iim1.iimSet(" | + | iret = iim1.iimSet("FNAME", rs.fields(0)) |
− | iret = iim1.iimSet(" | + | iret = iim1.iimSet("LNAME", rs.fields(1)) |
− | iret = iim1.iimSet(" | + | iret = iim1.iimSet("ADDRESS", rs.fields(2)) |
− | iret = iim1.iimSet(" | + | iret = iim1.iimSet("CITY", rs.fields(3)) |
− | iret = iim1.iimSet(" | + | iret = iim1.iimSet("ZIP", rs.fields(4)) |
− | iret = iim1.iimSet(" | + | iret = iim1.iimSet("STATE-ID", rs.fields(5)) |
− | iret = iim1.iimSet(" | + | iret = iim1.iimSet("COUNTRY-ID", rs.fields(6)) |
− | iret = iim1.iimSet(" | + | iret = iim1.iimSet("EMAIL", rs.fields(7)) |
'Run the macro | 'Run the macro | ||
'Note: This is the SAME macro, as in the FILE-2-WEB-METHOD2.VBS example script!!! | 'Note: This is the SAME macro, as in the FILE-2-WEB-METHOD2.VBS example script!!! | ||
Line 200: | Line 149: | ||
WScript.Quit(0) | WScript.Quit(0) | ||
− | ==Tabbed Browser [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ff-icon.png|Firefox]]== | + | ==Tabbed Browser [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]] [[Image:Cr-icon.png|Chrome]]== |
− | [[ | + | [[File:Tabbed_Browser.png|700px|thumb|Using Tabs]] |
− | + | Related example macros: [[Demo-Tabs]] | |
− | The iMacros Browser | + | The iMacros Browser includes a tabbed browsing interface that makes managing web sites with multiple open pages a snap. When a web page opens a new window iMacros automatically opens it in a new tab in the background. If the user changes to another tab a TAB command is automatically added during recording. |
− | You can close tabs while browsing by right-clicking on the tabs (not the browser window itself!). This will open up a context menu with the options to close the tabs. The following example shows the basic actions you can do with the TAB command | + | You can open or close tabs while browsing by right-clicking on the tabs (not the browser window itself!). This will open up a context menu with the options to open, close the current or other tabs. While recording, the appropriate command will be added to the macro. The following example shows the basic actions you can do with the TAB command |
' open a webpage in the first tab | ' open a webpage in the first tab | ||
− | URL GOTO=http://www. | + | URL GOTO=http://www.imacros.net |
' open a new tab | ' open a new tab | ||
TAB OPEN | TAB OPEN | ||
Line 222: | Line 171: | ||
TAB T=1 | TAB T=1 | ||
− | ==Frames [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]]== | + | If you are using iMacros for IE, it is important that you enable IE to open popups in tabs (Internet Options in IE Tools menu) if you want to use this feature. |
+ | |||
+ | ==Frames [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]] [[Image:Cr-icon.png|Chrome]]== | ||
[[Image:Frame-dom-inspector-f6.png|150px|thumb|Frame in Object Tree]] | [[Image:Frame-dom-inspector-f6.png|150px|thumb|Frame in Object Tree]] | ||
− | iMacros handles pages with frames automatically. It inserts FRAME statements that indicate to which frame the following TAG | + | iMacros handles pages with frames automatically. It inserts FRAME statements that indicate to which frame the following TAG or similar command refers. Please note that TAG will fail if it is not directed to the correct frame. |
− | |||
− | |||
− | |||
− | + | If the frame has a name, iMacros will use it in the FRAME statement, otherwise its index (the position of the frame in the page's object tree) is used. | |
− | + | ;Hint | |
+ | :When recording in the iMacros Browser or Internet Explorer, use Recording Mode = Expert (Complete HTML) to get the frame number as a comment in the recorded macro. Later you can edit your macro and decide which suits better your needs. Some websites use random names but fixed indexes, in this case it is better to refer to the frame number instead of the default frame name. | ||
− | ==Fine Tune TAG Commands [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]]== | + | ==Fine Tune TAG Commands [[Image:IMacros-icon.png|iMacros Browser]] [[Image:Ie-icon.png|IE Plug-in]] [[Image:Ff-icon.png|Firefox]] [[Image:Cr-icon.png|Chrome]]== |
Normally the TAG commands work the way they are recorded by iMacros, but sometimes you need to manually fine tune them. If an error occurs during replaying a TAG command it might be due to one of the following problems. | Normally the TAG commands work the way they are recorded by iMacros, but sometimes you need to manually fine tune them. If an error occurs during replaying a TAG command it might be due to one of the following problems. | ||
Line 255: | Line 204: | ||
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/kb/ki.dll/ke.kb.gz?kbb;*&&2&&&&&nc ATTR=NAME:zipcode CONTENT=85250 | TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/kb/ki.dll/ke.kb.gz?kbb;*&&2&&&&&nc ATTR=NAME:zipcode CONTENT=85250 | ||
− | Actually, you could also remove most of the static parts of the FORM information as well. Exactly how much you can remove depends on the website. You still need enough information for iMacros to uniquely identify the page element. In our example, the result looks like: | + | Actually, you could also remove most or all of the static parts of the FORM information as well. Exactly how much you can remove depends on the website. You still need enough information for iMacros to uniquely identify the page element. In our example, the result looks like: |
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/kb/* ATTR=NAME:zipcode CONTENT=85250 | TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/kb/* ATTR=NAME:zipcode CONTENT=85250 | ||
+ | |||
+ | or even | ||
+ | |||
+ | TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:zipcode CONTENT=85250 | ||
+ | |||
+ | '''Note:''' ''TXT:* is not the same as TXT: (without *).'' If only TXT: is used, this means you are looking for an element where the text attribute is "", if you are using TXT:* this means that the text attribute can have any value (= same as omitting the text attribute altogether). This applies to any attribute, not just TXT. | ||
+ | |||
+ | =====Related forum posts:===== | ||
+ | |||
+ | * [http://forum.imacros.net/viewtopic.php?t=11663 Click every button on a webpage using wildcards.] |
Revision as of 08:20, 17 August 2017
Introduction
Are you tired of filling out the same form over and over again? Then let iMacros help you. Simply put all data to be input into a very straightforward and easily understandable text file and iMacros can read the data from there and submit it to the web site - completely automatic, without your interaction!
Put your data in a comma separated text file (CSV format), which can be generated and edited by Microsoft Excel and many other applications, and iMacros will do the rest.
More advanced users might connect directly to databases to retrieve the data.
Related example macros: Demo-Datasource, Demo-Loop-Csv-2-Web
Related example script: File-2-Web.vbs, File-2-Web-Method2.vbs, Database-2-Web.vbs
Variables
Related example macros: Demo-Datasource, Demo-Slideshow
Note: Not all iMacros editions support all variables as described below. Please refer to Features Comparison to see your iMacros edition's support of variables.
Variables are, as the name suggests, constructs that allow you to dynamically, usually during runtime, hold different values. This is very helpful when you are trying to follow links that contain changing words or when you want to use the same macro for entering different values into a search engine.
The values (content) of all variables in iMacros are accessed by putting two curly brackets around the variable name. The values of !VAR1 is thus accessed by {{!VAR1}}.
Variables can be part of anything inside the macro (except the commands themselves). For example, you can add them as part of the ATTR string in a TAG or EXTRACT command or as part of the URL statement:
URL GOTO=https://www.onlinestore.com/?shoppingcart={{!VAR1}}&item={{!VAR2}}
You can assign almost any value to a variable. However, when assigning a value to a variable with SET certain characters need to be escaped or substituted because they imply a certain behaviour to iMacros. When assigning values to variables all whitespaces in the value part must be substituted by <SP> and all newlines must be substituted by <BR>; double curly brackets must be escaped with #NOVAR# ie. #NOVAR#{{. Note this this only applies inside a macro, e. g with the TAG, SET or ADD commands. If you use the iimSet command of the Scripting Interface, it replaces " " with <SP> and newline with <BR> automatically.
There are two kinds of variables in iMacros:
Built-in variables
These variables are used to define certain properties of the macro's behavior, for example the macro timeout value:
SET !TIMEOUT_MACRO 300
There is a set of special built-in variables, !VAR1, !VAR2, ..., !VAR9, !VAR0, which can be set to anything you like. They are also defined with the SET command
SET !VAR1 hello<SP>world
Alternatively, you can prompt the user to input a value:
PROMPT "Please enter text" !VAR1
User-defined Variables
These variables are created during runtime ("on the fly"). There are 3 different ways of creating variables:
1. You may use the command line switch -var_MYVAR like in
imacros.exe -macro myMacro -var_ITEM 15
which creates the variable ITEM during replay of the macro myMacro and gives it the value 15.
2. The second options is to use the iimSet function of the Scripting Interface. In a Visual Basic Script example this would look like:
iret = imacros.iimSet("ITEM", "15")
3. Or you may simply use the SET command as in
SET ITEM 15
Note that the user-defined variables should not have a prefixed "!". Only the built-in ones do, like e.g. !LOOP.
Data Input
Input from Comma Separated Data (CSV) File
Related examples: Demo-Loop-Csv-2-Web, File-2-Web.vbs
iMacros allows you to specify a text file with comma separated values (CSV) to be used as input. Imagine, for example, that you want to submit a list of CD's to an online auction. Here is the list of the CD's in the comma separated format:
"ARTIST" , "ALBUM TITLE" , "PRICE" "Beatles", "Abbey Road", "13.49" "Beatles", "The Beatles 1,2,3" , "25.49" "Mozart" , "Symphonies No.40 & 41", "9.98" "Mozart", "Requiem", "7.50"
Note: Quotation marks are optional in most cases. They are only required if the value itself contains a comma, a quotation mark, or a new line.
We now need to write in the macro where the data input file can be found. For that we use the built-in variable !DATASOURCE
SET !DATASOURCE OnlineAuction.csv
If you do not use any path information (like C:\myPath\) in the !DATASOURCE value the file is assumed to lie in the standard datasources directory, which can be specified in the Paths tab in iMacros Settings. The default directory is in the datasources\ directory of your iMacros personal folder (e.g. C:\Users\Me\Documents\iMacros).
Since we want to insert all datasets into the form we need to loop over the macro, each time inserting the next CD. Therefore, we need to tell iMacros in which line of the datasource we currently are. We do this using the built-in variable !DATASOURCE_LINE. By cunningly using the built-in variable !LOOP we let iMacros take care of the counting. And since the first line is just the header, we would like to skip it and start counting from 2:
SET !LOOP 2 SET !DATASOURCE_LINE {{!LOOP}}
Now we can have the macro fill out the online form with the values from the current CD dataset. We use the built-in variables !COLn, where n represents the number of the columns to put into the form element.
TAG TYPE=INPUT:TEXT FORM=Listing ATTR=NAME:Name CONTENT={{!COL1}} TAG TYPE=INPUT:TEXT FORM=Listing ATTR=NAME:Album CONTENT={{!COL2}} TAG TYPE=INPUT:TEXT FORM=Listing ATTR=NAME:Price CONTENT={{!COL3}}
During the execution of the macro the constants in brackets {{..}} are replaced by the value specified in the data sources.
Set the maximum number of times to repeat the macro to number of the last line you want to reach in your CSV file, and press Play.
Input from Database
Related example script: File-2-Web-Method2.vbs, Database-2-Web.vbs
iMacros can read data directly from any Windows database using the Scripting Interface and a few lines of code. Not all editions of iMacros comes with the Scripting Interface, please refer to the Features Comparison page to see if your iMacros support this feature.
This example code in Visual Basic Script connects to a Microsoft Access database:
' open database set rs = CreateObject("ADODB.Connection") rs.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" _ & mypath & "IIM-TEST-SUBMIT.MDB") ' use SQL to select information sql = "select * from table1" set rs = rs.Execute(sql) ' start iMacros set iim1= CreateObject ("iMacros") iret = iim1.iimInit iret = iim1.iimDisplay("Submitting Data from MS ACCESS") ' loop through result dataset do until rs.eof 'Set the variable iret = iim1.iimSet("FNAME", rs.fields(0)) iret = iim1.iimSet("LNAME", rs.fields(1)) iret = iim1.iimSet("ADDRESS", rs.fields(2)) iret = iim1.iimSet("CITY", rs.fields(3)) iret = iim1.iimSet("ZIP", rs.fields(4)) iret = iim1.iimSet("STATE-ID", rs.fields(5)) iret = iim1.iimSet("COUNTRY-ID", rs.fields(6)) iret = iim1.iimSet("EMAIL", rs.fields(7)) 'Run the macro 'Note: This is the SAME macro, as in the FILE-2-WEB-METHOD2.VBS example script!!! iret = iim1.iimPlay("wsh-submit-2-web") If iret < 0 Then MsgBox iim1.iimGetLastError() End If rs.movenext loop iret = iim1.iimDisplay("Done!") iret = iim1.iimExit WScript.Quit(0)
Tabbed Browser
Related example macros: Demo-Tabs
The iMacros Browser includes a tabbed browsing interface that makes managing web sites with multiple open pages a snap. When a web page opens a new window iMacros automatically opens it in a new tab in the background. If the user changes to another tab a TAB command is automatically added during recording.
You can open or close tabs while browsing by right-clicking on the tabs (not the browser window itself!). This will open up a context menu with the options to open, close the current or other tabs. While recording, the appropriate command will be added to the macro. The following example shows the basic actions you can do with the TAB command
' open a webpage in the first tab URL GOTO=http://www.imacros.net ' open a new tab TAB OPEN ' get new tab to foreground TAB T=2 ' load another page URL GOTO=http://www.google.com ' close the second tab TAB CLOSE TAB T=1
If you are using iMacros for IE, it is important that you enable IE to open popups in tabs (Internet Options in IE Tools menu) if you want to use this feature.
Frames
iMacros handles pages with frames automatically. It inserts FRAME statements that indicate to which frame the following TAG or similar command refers. Please note that TAG will fail if it is not directed to the correct frame.
If the frame has a name, iMacros will use it in the FRAME statement, otherwise its index (the position of the frame in the page's object tree) is used.
- Hint
- When recording in the iMacros Browser or Internet Explorer, use Recording Mode = Expert (Complete HTML) to get the frame number as a comment in the recorded macro. Later you can edit your macro and decide which suits better your needs. Some websites use random names but fixed indexes, in this case it is better to refer to the frame number instead of the default frame name.
Fine Tune TAG Commands
Normally the TAG commands work the way they are recorded by iMacros, but sometimes you need to manually fine tune them. If an error occurs during replaying a TAG command it might be due to one of the following problems.
Wildcards
Some web sites are created dynamically from databases and the links contain unique numbers - the so-called session ID - each time you visit a page. While this technique helps the web site owner it poses a problem to iMacros. This is because during recording the session ID, which is often part of links, was written into the macro as part of the TAG command. During replay the session ID is different, thus iMacros does not find the exact link and produces an error. The solution is to replace the changing part of a link (or extraction) with the * symbol, which is read by iMacros as a wildcard. The wildcard causes iMacros to accept any character where the * is placed.
Example
Tag line as recorded by iMacros:
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/kb/ki.dll/ke.kb.gz?kbb;532452&&2&&&&&nc ATTR=NAME:zipcode CONTENT=85250
If you record the same macro a second time you will see that we get the same TAG line except one number - this is the session ID the website is using.
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/kb/ki.dll/ke.kb.gz?kbb;532244&&2&&&&&nc ATTR=NAME:zipcode CONTENT=85250
Replace the session ID with *:
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/kb/ki.dll/ke.kb.gz?kbb;*&&2&&&&&nc ATTR=NAME:zipcode CONTENT=85250
Actually, you could also remove most or all of the static parts of the FORM information as well. Exactly how much you can remove depends on the website. You still need enough information for iMacros to uniquely identify the page element. In our example, the result looks like:
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/kb/* ATTR=NAME:zipcode CONTENT=85250
or even
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:zipcode CONTENT=85250
Note: TXT:* is not the same as TXT: (without *). If only TXT: is used, this means you are looking for an element where the text attribute is "", if you are using TXT:* this means that the text attribute can have any value (= same as omitting the text attribute altogether). This applies to any attribute, not just TXT.