OK, in case some of the following can be useful to somebody, here is my testing procedure:
- I made a single page simple form in PHP, saving the data so I can check the result:
- <body>
-
- <h1>Filling Form Fields</h1>
-
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
- <fieldset><legend>User Input</legend>
- <label for="firstName">First Name:</label><input type="text" name="firstName" id="firstName" size="50"/><br/>
- <label for="lastName">Last Name:</label><input type="text" name="lastName" id="lastName" size="50"/><br/>
- <label for="address1">Address 1:</label><input type="text" name="address1" id="address1" size="100"/><br/>
- <label for="address2">Address 2:</label><input type="text" name="address2" id="address2" size="100"/><br/>
- <label for="city">City:</label><input type="text" name="city" id="city" size="50"/><br/>
- <label for="postalCode">Postal Code:</label><input type="text" name="postalCode" id="postalCode" size="7"/><br/>
- <label for="email">E-mail:</label><input type="text" name="email" id="email" size="50"/><br/>
- <input type="submit"/>
- </fieldset>
- </form>
-
- </body>
- </html>
-
- <?php
- if (!isset($_POST['firstName']))
- return; // Just display the page
- $firstName = htmlspecialchars(@$_POST['firstName']);
- $lastName = htmlspecialchars(@$_POST['lastName']);
- $address1 = htmlspecialchars(@$_POST['address1']);
- $address2 = htmlspecialchars(@$_POST['address2']);
- $city = htmlspecialchars(@$_POST['city']);
- $postalCode = htmlspecialchars(@$_POST['postalCode']);
- $email = htmlspecialchars(@$_POST['email']);
- addData($firstName, $lastName, $address1, $address2, $city, $postalCode, $email);
- ?>
-
- <?php
- function addData($firstName, $lastName, $address1, $address2, $city, $postalCode, $email)
- {
- $data = <<<DATA
- ### $firstName $lastName ###
- $address1
- $address2
- $city, $postalCode
- $email
-
- DATA;
- $fileName = "DataBase.txt";
- $fh = fopen($fileName, 'a') or die("Cannot open for write " . $fileName);
- fwrite($fh, $data);
- fclose($fh);
- }
- ?>
(header part omitted for brevity)
The script was on my local www folder, so it was reachable via localhost URL.
- I recorded a iMacros script filling in this form and submitting it. The result was looking like:
- VERSION BUILD=7601105 RECORDER=FX
- TAB T=1
- URL GOTO=http://localhost/Tests/TestIMacros.php
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:firstName CONTENT=a
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:lastName CONTENT=b
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:address1 CONTENT=c
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:address2 CONTENT=d
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:city CONTENT=e
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:postalCode CONTENT=f
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:email CONTENT=g
- TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/Tests/TestIMacros.php ATTR=*
- I went to
IdentityGenerator and generated a CSV file of 100 random entries. I used the | separator because there can be commas in the addresses and IG doesn't quote its fields... I then used search / replace in my editor to replace | with "," and to add " to the beginning and end of the lines.
- I changed the above script to use the CSV file, following the instructions on the site:
- VERSION BUILD=7601105 RECORDER=FX
- TAB T=1
- SET !DATASOURCE C:\www\Tests\randomdata.csv
- SET !DATASOURCE_COLUMNS 7
- SET !LOOP 2
- SET !DATASOURCE_LINE {{!LOOP}}
- URL GOTO=http://localhost/Tests/TestIMacros.php
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:firstName CONTENT={{!COL1}}
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:lastName CONTENT={{!COL2}}
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:address1 CONTENT={{!COL3}}
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:address2 CONTENT={{!COL4}}
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:city CONTENT={{!COL5}}
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:postalCode CONTENT={{!COL6}}
- TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/Tests/TestIMacros.php ATTR=ID:email CONTENT={{!COL7}}
- TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/Tests/TestIMacros.php ATTR=*
- I ran the script, telling to loop 100 times.
In less than a minute, with browser minimized, it filled in the form 100 times.
I think iMacros is able to fill in a multi-page form as well. Maybe some delays must be inserted between submits.
It is a valuable tool where such repetitive task is needed.