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 "Demo-Loop-Csv-2-Web"
(17 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
− | Demonstrates automatic data entry with the LOOP button: Reads | + | Demonstrates automatic data entry with the LOOP button: Reads data from a simple text file in [[csv|CSV]] format and submits it to a web site. |
+ | |||
+ | Please note that you need to use the '''"Play (Loop)"''' button instead of the regular "Play" button if you want to loop through a CSV file. Also don't forget to set the "Max" text box value to the number of the last line you want to reach in your CSV file. | ||
+ | |||
+ | '''Related Screencast Tutorial:''' [http://forum.imacros.net/_uploads/iim-amazon-csv-file-input.htm Read/import values to a website from a file (Amazon.com)] | ||
+ | |||
+ | See also the [[Web_Testing#Table-Driven_Testing|Table-Driven Testing]] chapter, it shows how to use this feature for quick and easy web testing. | ||
+ | |||
+ | Macro Code | ||
+ | |||
+ | <nowiki> | ||
+ | VERSION BUILD=10.4.28.1074 | ||
+ | 'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database | ||
+ | TAB T=1 | ||
+ | TAB CLOSEALLOTHERS | ||
+ | ' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file | ||
+ | 'CSV = Comma Separated Values in each line of the file | ||
+ | SET !DATASOURCE Address.csv | ||
+ | 'Start at line 2 to skip the header in the file | ||
+ | SET !LOOP 2 | ||
+ | 'Increase the current position in the file with each loop | ||
+ | SET !DATASOURCE_LINE {{!LOOP}} | ||
+ | ' Fill web form | ||
+ | URL GOTO=http://demo.imacros.net/Automate/AutoDataEntry | ||
+ | TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:fname CONTENT={{!COL1}} | ||
+ | TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:lname CONTENT={{!COL2}} | ||
+ | TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:address CONTENT={{!COL3}} | ||
+ | TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:city CONTENT={{!COL4}} | ||
+ | TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:zip CONTENT={{!COL5}} | ||
+ | ' | ||
+ | 'Note * is used to ignore leading and trailing blanks that could be in the input data | ||
+ | ' | ||
+ | 'The precent (%) symbol is used to select the stateid by VALUE as defined in the website select statement and not by its index. | ||
+ | TAG POS=1 TYPE=SELECT FORM=ID:demo ATTR=NAME:state CONTENT=$*{{!COL6}}* | ||
+ | ' | ||
+ | 'The string ($) symbol is used to select the country by TEXT, not by its index. | ||
+ | 'Index would be the position of an entry in the combo box list, e. g. 161 for United States | ||
+ | TAG POS=1 TYPE=SELECT FORM=ID:demo ATTR=NAME:country CONTENT=$*{{!COL7}}* | ||
+ | ' | ||
+ | TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:email CONTENT={{!COL8}} | ||
+ | TAG POS=1 TYPE=BUTTON:submit FORM=ID:demo ATTR=TXT:Submit | ||
+ | |||
+ | TAG POS=1 TYPE=A ATTR=TXT:*Back* | ||
+ | </nowiki> |
Revision as of 10:01, 27 February 2017
Demonstrates automatic data entry with the LOOP button: Reads data from a simple text file in CSV format and submits it to a web site.
Please note that you need to use the "Play (Loop)" button instead of the regular "Play" button if you want to loop through a CSV file. Also don't forget to set the "Max" text box value to the number of the last line you want to reach in your CSV file.
Related Screencast Tutorial: Read/import values to a website from a file (Amazon.com)
See also the Table-Driven Testing chapter, it shows how to use this feature for quick and easy web testing.
Macro Code
VERSION BUILD=10.4.28.1074 'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database TAB T=1 TAB CLOSEALLOTHERS ' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file 'CSV = Comma Separated Values in each line of the file SET !DATASOURCE Address.csv 'Start at line 2 to skip the header in the file SET !LOOP 2 'Increase the current position in the file with each loop SET !DATASOURCE_LINE {{!LOOP}} ' Fill web form URL GOTO=http://demo.imacros.net/Automate/AutoDataEntry TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:fname CONTENT={{!COL1}} TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:lname CONTENT={{!COL2}} TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:address CONTENT={{!COL3}} TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:city CONTENT={{!COL4}} TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:zip CONTENT={{!COL5}} ' 'Note * is used to ignore leading and trailing blanks that could be in the input data ' 'The precent (%) symbol is used to select the stateid by VALUE as defined in the website select statement and not by its index. TAG POS=1 TYPE=SELECT FORM=ID:demo ATTR=NAME:state CONTENT=$*{{!COL6}}* ' 'The string ($) symbol is used to select the country by TEXT, not by its index. 'Index would be the position of an entry in the combo box list, e. g. 161 for United States TAG POS=1 TYPE=SELECT FORM=ID:demo ATTR=NAME:country CONTENT=$*{{!COL7}}* ' TAG POS=1 TYPE=INPUT:TEXT FORM=ID:demo ATTR=NAME:email CONTENT={{!COL8}} TAG POS=1 TYPE=BUTTON:submit FORM=ID:demo ATTR=TXT:Submit TAG POS=1 TYPE=A ATTR=TXT:*Back*