Web Testing

From iMacros
Jump to: navigation, search

"iMacros has been an excellent addition to our development toolbox."

Ian Dominioni, United Parcel Service (UPS)


Performance Testing iMacros Browser IE Plug-in Firefox

(Related example macro: Demo-Stopwatch) (Related example script: get-response-times.vbs) iMacros includes full support for in-depth performance testing (response time measurements).

There are two approaches: Looking at the performance log (also called performace profiler) of the macro or inserting STOPWATCH commands at specific points in your macro. The performance profile is best if you do not know (yet) where to expect bottlenecks or issues. The STOPWATCH command has the advantage of creating less data and is best suited for monitoring known performance issues (e. g. the submit button in a shopping cart, when a 3rd party API is called).

Performance Profiling

This feature is new since iMacros V7.35. Please see Performance Profiler for details.

STOPWATCH

The STOPWATCH command in iMacros allows you to measure the time that elapses between the first occurrence of the command in a macro ( = stopwatch on) and the second occurrence ( = stopwatch off). By using different identifiers in the STOPWATCH command you can create up to 100 independent measurement points in your macro.

In order to do web site response measurements you need to insert the STOPWATCH statements manually after you recorded your macro. For accurate measurements it is important to set the browsers replay speed to FAST so no artificial delays are added.

Demo Movie: Performance Web Testing with STOPWATCH

iMacros response time measurements always reflects the true user experience as they are measured using a real browser. Therefore response times measured by iMacros include loading times for browser plug-ins such as the Macromedia Flash Player or the Java runtime.

By default the measured times are saved to the Downloads\ directory of your iMacros installation (e.g. C:\Program Files\iMacros\Downloads\). The default file name is macroName_stopwatch.csv. You can instruct iMacros to save the data to a custom file name by setting the built-in variable !FILESTOPWATCH.

The values are comma separated (CSV format) so they can be viewed with any text editor, imported directly in Microsoft Excel or viewed by any other software you use. Additional information about the date and time of the measurements and the calling macro will be added to the response times.

In this example we measure response times of different parts of the iOpus homepage:

VERSION BUILD=4230323  
SET !FILESTOPWATCH mydata.csv     
STOPWATCH ID=total 
URL GOTO=http://www.iopus.com/imacros/       
STOPWATCH ID=1   
TAG POS=1 TYPE=A ATTR=HREF:http://www.iopus.com/imacros/compare 
STOPWATCH ID=1 
STOPWATCH ID=store    
TAG POS=1 TYPE=A ATTR=TXT:US$<SP>149    
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:order ATTR=NAME:ORDER_PRODUCT_NOW&&VALUE:Order<SP>Now   
TAG POS=1 TYPE=A ATTR=HREF:http://www.iopus.com/store 
STOPWATCH ID=store 
STOPWATCH ID=total 

This macro will create the following data in the "mydata.csv" file - obviously the response times will be different when you replay this macro. The format of the file is:

YYYY/MM/DD, HH:MM:SS, Macro name, ID, time (s) 
"2007/08/3","11:56:23","mymacro","1","1.272" 
"2007/08/3","11:56:32","mymacro","store","8.943" 
"2007/08/3","11:56:32","mymacro","total","10.21" 

For more information please see the Tips for Accurate Web Response Time Measurements.

Automating Response Time Measurements

(Related example script: get-response-times.vbs )

If you want to automate reponse time measurements it is likely that you will call iMacros from another application. Instead of writing the response time to a log file the data can be sent to your application via the Scripting Interface. Simply use the extract feature. The last recorded response time value is stored in the built-in !STOPWATCHTIME variable. You can use this variable as follows to transfer the response time data to the calling script or program:

VERSION BUILD=4230323  

SET !FILESTOPWATCH NO

STOPWATCH ID=total 
URL GOTO=http://www.iopus.com/iim/iim/demo/v4    
STOPWATCH ID=1   
TAG POS=1 TYPE=A ATTR=HREF:http://www.iopus.com/iim/compare 
STOPWATCH ID=1 
SET !EXTRACTADD {{!STOPWATCHTIME}} 
STOPWATCH ID=store    
TAG POS=1 TYPE=A ATTR=TXT:US$<SP>149    
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:order ATTR=NAME:ORDER_PRODUCT_NOW&&VALUE:Order<SP>Now   
TAG POS=1 TYPE=A ATTR=HREF:http://www.iopus.com/store 
STOPWATCH ID=store 
SET !EXTRACTADD {{!STOPWATCHTIME}} 
STOPWATCH ID=total 
SET !EXTRACTADD {{!STOPWATCHTIME}} 

Thus, the data is added to the !EXTRACT variable. Its contents can be obtained via the "iimGetLastExtract" command. In the above example it contains the three recorded response times (Example string):

1.272[EXTRACT]8.943[EXTRACT]10.21[EXTRACT] 

Note: "SET !FILESTOPWATCH NO" instructs iMacros not to create a response time log file. This is useful if you intend to return the values via the Scripting Interface.

Tips for Accurate Web Response Time Measurements

Sample measurements with a modified Demo-Stopwatch macro running on the iOpus.com Dallas monitoring server
  • Add a CLEAR statement to your macro. This way you can make sure that the browser cache is cleared before each run. Otherwise iMacros might read the web pages from the cache and not the web server, which would most likely result in lower response times. Whether the cache is actually used depends on the Internet Explorer settings.
  • Run the measurements as a loop and average several runs. The "internet speed" can fluctuate from minute to minute even on a fast connection. Therefore differences between each measurement run are normal. To get stable results it is good practice to average several runs. Several common programs such as Microsoft Excel can create averages automatically for you.
  • If you compare results between different PC's, please keep in mind that the accuracy depends on the accuracy of the PC clock. This applies to all software that does time measurements on a PC.
  • Under normal conditions the processor speed does not influence the measured response times. Only if the PC is so slow that the web page rendering of the browser is slowed down will the CPU speed have an influence on the measured response time. iMacros response time measurements always reflect the true user experience as they are measured using a real browser and the original browser plug-ins such as Macromedia Flash Player or SUN Java runtime.
  • On very complex web applications it can happen that a STOPWATCH command around a URL GOTO command correctly measures the time for a page to open, but stops the time measurement when the page is still loading and displaying "Loading". In such a case, please use a keyword check (e. g. with a TAG or IMAGESEARCH) command to check that the page is loaded completely. This way you can measure the exact time from page access, to the completion of the page load.

Example: Instead of

 STOPWATCH ID=Firstpage
 URL GOTO=http://www.iopus.com/imacros/demo/v6/flash/   
 STOPWATCH ID=Firstpage 

Please use:

 STOPWATCH ID=Firstpage
 URL GOTO=http://www.iopus.com/imacros/demo/v6/flash/     
 IMAGESEARCH IMAGE=flashEnter.bmp CONFIDENCE=90
 STOPWATCH ID=Firstpage

How to measure browser rendering time

To measure only the in-browser rendering time of your site, simply test the website via a local intranet connection or directly on the web server. This sets the page load time effectively to zero, thus any delay measured by iMacros is the browser rendering time of your web application.

Regression Testing iMacros Browser IE Plug-in Firefox

Regression testing with iMacros is easy and very flexible. Please this Regression Testing FAQ and the Reporting options.

Table-Driven Testing

Table-driven testing, also known as keyword-driven testing or action-word testing, is a software testing methodology for automated testing that separates the test creation process into two distinct stages: a planning stage, and an implementation stage.

It is an easy-to-use and very flexible form of data-driven testing. The difference is that the test case is contained in the set of data values and not embedded or "hard-coded" in the test script itself. The script is simply a "driver" (or delivery mechanism) for the data that is held in the data source.

A more complex keyword (a combination of keywords into a meaningful unit), e.g. logging in.

User Password Selection1
Tim 65665 USD
Tom 67%&PK EURO
Jack §$$$$6565 YEN
Maya mypwdiseasy USD

iMacros has built-in support for table-driven testing with its ability to read all csv formatted files (tables). No additional coding or scripting is required. You can use any numbers of columns, and all kinds of column content is supported (including full Unicode support). The number of table columns is automatically detected.

For more details, please see Input from Comma Separated Data File and the documentation for the !COLn and !DATASOURCE variables. They are used to merge the input table data with the testing script (macro). iMacros includes the Demo-Loop-Csv-2-Web macro that demos this feature.

Load Testing iMacros Browser IE Plug-in Firefox

Most load testing tools simulate users at the HTTP layer - simulating only the traffic that is generated by the browser, rather than simulating the entire browser.

iMacros is different. iMacros emulate user behavior, making AJAX, Flash, Flex, Java and Silverlight load testing trivial. It works by testing the complete web application inside the browser (Internet Explorer (IE), Firefox, iMacros Browser) and gives you 100% realistic testing data to accurately reflect true end-user experiences. This includes load testing websites with AJAX, Flash, Flex, Silverlight or Java applets.

This approach requires that each simulated user has his own browser instance. You can run several instances of iMacros at once, thus simulating concurrent users. This approach works very well for 1...50 users per average PC. The limit is only the number of IE or Firefox instances than can run on your machine. As a rule of thumb, simulating up to 50 concurrent users on a single machine is no problem. You can use the low cost iMacros Player Unlimited User license to install iMacros on many machines to increase the load at no extra cost (Unlimited Virtual Users). As an example, if you have access to five machines, you can generate a load of up to 250 concurrent users.

You can use the STOPWATCH command to measure the web application performance in great detail during your load test.

Note that the number of concurrent users that you need to simulate for load testing is very small compared to the number of monthly visitors:

 concurrent = (visits_per_month * average_time_on_site) / (3600 * 24 * 30)

So if you e.g. have 30,000 visits per month, and the average visitor spends 3 minutes on your site (180 seconds), it means your average number of concurrent visitors will be (30000 * 180) / (3600 * 24 * 30) = 2.048 or just over 2 visitors. However, this is the *average* number of visitors your site will have. Usually, peak hour traffic will be a lot higher and low traffic hours a lot lower. How much higher peak traffic is than average traffic can vary depending on what site you have, just as average time on site will vary depending on the type of site you have.

(Observe also, that it is important to use the total number of visits - not the number of unique visitors - when calculating average number of concurrent visitors)

Testing AJAX websites

Ajax-driven or JavaScript-heavy sites often require different strategies than when testing a regular site: elements appear, disappear and change at any time. Because of its built-in "intelligence" iMacros can automate many AJAX based websites using standard HTML based TAG commands. And it can automate absolutely all AJAX elements with DirectScreen Technology. This allows in-browser testing of even the most complicated AJAX elements, including sliders and drag & drop activity.

Related Demo-Macros:

Forum posts:

Website Monitoring

iMacros is ideally suited for web performance monitoring and synthetic user monitoring (transaction monitoring, testing websites with real browsers). For this purpose the iMacros team has created the popular AlertFox website monitoring service. Give it a try and sign up for a free website monitoring account. And continuously test and measure your website performance with your iMacros macros.

Reporting iMacros Browser IE Plug-in Firefox

iMacros has several reporting options. You can use the default reports or use the iMacros scripting features to create any kind of report.

1. Global logfile (lists any issues that might have occurred, such as website not available) with date and time.

2. Per macro reports, same as #1, but per macro.

3. Performance reports with the STOPWATCH command

4. Screenshots: iMacros can take screenshots during the iMacros run, so you can see what went wrong (e.g. an image missing or formatting issue).

5. Custom reports: You can create any kind of report via the Scripting Interface. This includes writing the test results to a log file (e. g. Combine-Macros.vbs) or taking a screenshot of the web browser after an error has occurred. You can also use this interface to connect iMacros directly with any kind of software or program, e. g. test planning software.

All functions and the test runs can be scheduled as well.

If you have any reporting requirement that is not covered here, please let us know.

Change User Agent

Related example: Set-User-Agent.vbs (VBS script)

Every time you access a web site the browser you use sends a string to the web server containing information about your operating system and the browser you are using. This string might, for example, look like this:

Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)

Sometimes it is desirable to pretend to be a different user agent because some web sites change in behaviour or appearance depending on the user agent. iMacros can simulate all user agent strings with the -useragent command line switch. The command line switch can also be used in iimInit command of the the Scripting Interface:

iret = iim1.iimInit ("-useragent ""Nokia6230/2.0+(04.43)""") iMacros Browser IE Plug-in

If your user agent contains spaces, please use double quotes ("") around it.

You can see the current user agent of iMacros at http://www.iopus.com/imacros/demo/v6/user-agent.htm

In iMacros for Firefox please use the following command inside the macro:

SET !USERAGENT "New User Agent here". Firefox

So with iMacros for Firefox the user agent can be changed during the macro runtime. With Internet Explorer, the user agent is defined when Internet Explorer is started.

Web Testing FAQs

Q: How can I detect if an error page is loaded?

The URL command itself can not distinguish between loading the "real" web page and an error page (ASP.NET error page, SQL error page, or 404 error page). Because in all these cases the (error) web page itself loads fine (no timeout).

But there is a simple solution: Use the TAG command to check for a keyword or image that exist only on the right (non-error) page.

Please see the next FAQs on how to do such a keyword check.

Q: How can I search for a specific keyword on a web page?

When parsing a web site you want to find out if a certain word exists on a web page to trigger further action (like saving the web page, printing the page or running the next macro). This is also called keyword assertion or regression testing.

There are many applications of the keyword search feature. For example tracking your search engine ranking, observing a (financial) news web site, get feedback on a failed login, watching web pages for changes or even monitoring trademark infringements automatically.

If the keyword does not exist, iMacros retries the keyword search automatically every second until the !TIMEOUT value is reached. If the keyword is still not found, iMacros reports an error. The automatic retry makes web testing websites with AJAX easy. For standard websites, you can also combine a keyword search with the REFRESH command to wait until a page changes. If you want to test without retry, please use SET !TIMEOUT 1 before the keyword search.

iMacros offers three options for keyword search (keyword assert):

1.	TAG command  
2.	TAG... EXTRACT command  
3.	IMAGESEARCH command  

Please see below for more details on each option. We also created the "Demo-Keyword-Check.iim" example macro.

(direct link to this FAQ)

Keyword Search with TAG

The TAG command searches for a HTML tag inside the web page. If found, it clicks on it. But TAG can also search for any kind of text on a web page. Thus, any TAG command is automatically a keyword assert command. For example

TAG POS=1 TYPE=STRONG ATTR=TXT:*iMacros*

searches for the word iMacros enclosed by the STRONG HTML tag. If you want to search for text regardless of the format, i.e. the enclosing HTML tag, please use the wildcard character * instead of a HTML tag:

TAG POS=1 TYPE=* ATTR=TXT:*iMacros*

This command is the same as above, but this time the command ignores the formatting of the keyword. This command takes longer, as iMacros needs to scan the complete page, not only certain html tags.

You can also "invert" the keyword search and generate an error if the keyword is found on the page:

TAG POS=1 TYPE=* ATTR=TXT:*iMacros* CONTENT=EVENT:FAIL_IF_FOUND

As the event suggests the TAG command will now generate an error if it succeeds.

Use of timeout when looking for text: There are two kinds of timeouts used by iMacros:

  • 1. iMacros waits for the page to load up to !TIMEOUT seconds. The default is 60s.
  • 2. After the page is loaded, iMacros checks for the text to appear. If the text is not found, it waits one second and re-checks the page!. It does this until the "TAG timeout" value is reached. It is always 1/10 of the regular timeout (default is 6s).

Related forum post: Keyword search / wait until keyword is found

Keyword Verification by Extracting Text

You can use the EXTRACT feature and make the keyword the extraction anchor. The general idea is to try and extract a certain piece of information and then check if the extraction result is the Extraction Anchor Not Found (#EANF#) message.

Example: We want to find out if the words "Order completed" are displayed on a web page. If yes, we want to print the page. To search the web page for the test phrase, create a macro called mysearch, which only has two lines:

VERSION BUILD=6140125 
TAG POS=1 TYPE=* ATTR=TXT:*Order<SP>completed* EXTRACT=TXT

In this example we are searching the web page for the first occurrence (POS=1) of the keyword "Order completed". If the message #EANF# is returned then the keyword was not found as the keyword is the data extraction anchor. If the keyword was found then the EXTRACT command returns the complete text of the found HTML tag. In our example this could be "Software Order completed".

To print the web page create a macro called print_this. It has only two lines:

VERSION BUILD=6140125 
PRINT 

To connect both macros together create a small Windows script:

set iim1= CreateObject ("imacros")
iret = iim1.iimInit()
iplay = iim1.iimPlay("mysearch")
extracted_text = iim1.iimGetLastExtract(1)

'test if keyword appeared on website.
If iplay = 1 Then
  If instr (extracted_text, "#EANF#") > 0 Then
    MsgBox ("Sorry, keywords not found")
  Else
    iplay = iim1.iimPlay("print_this")
  End If
End If

If iplay < 0 Then
  MsgBox "Error!"
End If

Note: The same procedure can be used to look for several keywords on a page, for example "cat", "dog" and "mouse":

The solution is to use several EXTRACT commands. So in the macro use:

TAG POS=1 TYPE=* ATTR=TXT:*mouse* EXTRACT=TXT 
TAG POS=1 TYPE=* ATTR=TXT:*cat* EXTRACT=TXT 
TAG POS=1 TYPE=* ATTR=TXT:*dog* EXTRACT=TXT 


In the script you can look at each array element to see if they keyword was found:

iplay = iim1.iimPlay("wsh-extract-rate")
If iplay = 1 Then
  If iim1.iimGetLastExtract(1) <> "#EANF#" Then MsgBox "Keyword CAT found!"
  If iim1.iimGetLastExtract(2) <> "#EANF#" Then MsgBox "Keyword DOG found!" 
  If iim1.iimGetLastExtract(3) <> "#EANF#" Then MsgBox "Keyword MOUSE found!" 
End If

Keyword Search with IMAGESEARCH

You can use the IMAGESEARCH command to look for keywords or keyimages. Thus, instead of a text you supply an image of the word:

Example (Image of the word "iMacros"): imacros

The advantage of this command is that it works on any type of web page, including Flash, Java, Silverlight or ActiveX controls. With these applets you can not extract the displayed data as text, but only as image. To verify that the correct text is displayed, create a small image of this text and then search for it with IMAGESEARCH. In the Demo-ImageRecognition macro this approach is used to validate the Flash calculator result.

We also recommend to take a screenshot of the complete browser with iimTakeBrowserScreenshot when your macro detects a page error. This is an excellent method to log such issues for later discussions with your colleagues.

For more details please see the Image Recognition Plugin chapter.

Q: I want to test that certain images will show up on my site when a page is loaded.

(a) Check that an image is present

The Save Item function includes an image checkpoint. If a image is missing, an error will occur. Example:

CLEAR
TAG POS=1 TYPE=IMG ATTR=TXT:*bee.jpg CONTENT=EVENT:SAVEITEM
TAG POS=1 TYPE=IMG ATTR=TXT:*shark.jpg CONTENT=EVENT:SAVEITEM

This macro will download two images. If one image is missing on the web page the macro stops with an "image not found" error. To make sure that the missing image is not stored in the browser cache it is recommended that you use the CLEAR command before this test.

This technique is also recommended if you are automating or testing web sites with complex frames. To make sure a specific frame is completely loaded do the above test for a specific image in this frame. iMacros will wait at the TAG.....EVENT:SAVEITEM command until this image appears.

The method is easily implemented if you have information about the image such as its own URL, the link URL or the alternative text. If all you have is the image itself use the IMAGESEARCH command of the Image Recognition Plugin.

(b) Check the content of an image

Please use the IMAGESEARCH command if you need to verify the content of an image.

Q: Does iMacros support checkpoints?

Yes! Please see the Checkpoints page for more details.

Q: Does iMacros support multiple checkpoints in one macro?

By design, a macro stops when an error occurs (see checkpoints). To verify multiple checkpoints there are two strategies:

1. Split the task in several sub macros, with one checkpoint per macro. A macro can be very small, and even contain only one line. Example:

 i = iim1.iimPlay ("Checkpoint1")
 if i < 0 then msgbox ("Checkpoint 1: Macro reports error.")
 i = iim1.iimPlay ("CODE:TAG POS=2 TYPE=A ATTR=TXT:*Download* ")
 if i < 0 then msgbox ("Checkpoint 2: Text not found.")
 i = iim1.iimPlay ("CODE:IMAGESEARCH IMAGE=result.bmp CONFIDENCE=90")
 if i < 0 then msgbox ("Checkpoint 3: Image not found.")

2. If you only need to verify text you can also use the Data Extraction features of iMacros to return the information to your script, and then process the result according to your business requirements.

Q: How to use iMacros with 3rd party tools?

iMacros can be integrated with almost any 3rd party tools (e.g. NUnit or SpiraTeam testing frameworks).

For the integration you can use

Related Case Study: Agilent Technologies uses the iMacros Scripting Interface to integrate iMacros with their WebTrans Software/QoS Manager. The QoS Manager is a powerful, dedicated Java based web testing and web monitoring framework used by major telcoms.

If you have questions about integrating iMacros with a specific third party software, please ask our tech support.

Q: How to invoke 3rd party tools from iMacros?

iMacros can interface with any 3rd party tool. To achieve this, call both, iMacros and the 3rd party tool from a script. Any programming language can be used for this via the powerful iMacros Web Scripting Interface.

All programming languages have slightly different methods to run programs, but the basic idea is always the same. Here is an example for VB Script:

Example:

 'Run iMacros Regression Test
 iErrorCode = iim1.iimPlay ("TestShoppingCartMacro")
 
 'Call 3rd party tool 
 Set objShell = CreateObject("WScript.Shell")
 iErrorCode = objShell.Run "3rdPartyTool.exe /cmd1 /cmd2"
 
 'You can also run Windows command line tools (MSDOS, Batch files,...) directly 
 iErrorCode = objShell.Run("ping www.mywebsite.com",,True)

If you have questions about a specific third party software, please ask our tech support.

Q: How does iMacros use variables?

Please see the answer to the question: Can iMaros run data driven tests?.

Q: Is there any way to verify if any javascript errors have been thrown?

Yes! You can run a regression test and ensure no errors came out of Javascript. To log Javascript error messages, please make sure that the display of Javascript error message is enabled. To enable it, uncheck the "Disable Script Debugging" option in the Internet Explorer Settings Dialog. These settings are also used by the iMacros Browser.

Extracting the text of a Javascript error message.

For more details please see the Page Errors chapter and ONERRORDIALOG. Related forum post: Take screenshots when Javascript errors occur.

Q: Can iMacros run data driven tests?

Yes! iMacros can read data and use it to fill forms and/or make special decisions during the macro run. There are two methods to connect iMacros with data sources.

1. Read CSV files directly. iMacros can import data directly into the {{!COL1}}, {{!COL2}},... variables. Please see the Demo-Loop-Csv-2-Web macro.

2. Use the Scripting Interface to connect to any database.

3. Use the Scripting Interface to call iMacros from any programming or scripting language.

Q: What effect does iMacros itself have on web application response measurements?

The overhead of iMacros itself is very thin. On a 3 GHz Pentium each macro step takes only about 20 ms (0.02s) of processing time. If you compare this to the average page response time the delay caused by iMacros itself is typically much less than 2%. Note that a few commands need more processor time, for example the CLEAR, IMAGESEARCH or IMAGECLICK commands.

Since the iMacros Browser is an IE-compatible browser, realistic viewer experience results are guaranteed. For example, your performance measurement results include the browser rendering time.

Q: How can I set up a 24 hours a day, 7 days a week (non-stop) operation with iMacros?

Many applications of iOpus iMacros require continuous operation of the software. Examples are the use of iMacros as part of payment gateway, extracting large volumes of information or web testing applications in general.

Problem: iMacros has the ability to remotely control the web browser and a wide variety of third-party browser plug-ins, such as Java virtual machine (Java applets), Adobe Acrobat Reader (PDF viewer), Macromedia Shockwave (Flash applets) and many others. By design most of these controls are not intended for 24x7 operations and running them repeatedly for several days can lead to undesirable effects, such as increased memory consumption ("memory leaks").

Solution: The Scripting Interface is a compact and reliable component that controls the iMacros browser and thus, all its plug-ins. The Scripting Interface was designed to automate web testing and at the same time to compensate for problems of the Windows Internet components used by the iMacros browser and third-party browser plug-ins.

Picture 1: Stable CPU and memory usage over time running the sample code listed below in part (b) with the "Demo-Flash" macro. The left part is a task manager snapshot taken on day 1 and the right part is taken on day 30. The snapshots were taken on a Windows Server 2003 with 2 GHz CPU and 512 MB Ram. Nowadays we recommend using Windows 2008 and better.

The image shows stable CPU and memory usage over time running the sample code listed below with the "Demo-Flash" macro. The left part is a task manager snapshot taken on day 1 and the right part is taken on day 30. The snapshots were taken on an old Windows Server 2003 with 2 GHz CPU and 512 MB Ram. Nowadays we recommend using Windows 2008 and better.

A periodic restart of the server is not required. However, as with any server application in general you should make sure that the application restarts correctly after the machine is rebooted or reset.

If you need to repeat a certain macro, for example five million times, do not start a single browser instance and use the Play (Loop) button. Instead use the Scripting Interface for the loop. In VBS code this looks like:

'Sample code A
Set iim1= CreateObject ("imacros")
For m = 1 to 5000000
    iret = iim1.iimInit()
    iret = iim1.iimPlay("macro1")
    iret = iim1.iimExit()
Next

This command sequence closes the browser after each macro and thus avoids browser memory leaks. Even if the browser or one of its plug-ins "hangs" or"crashes", the Scripting Interface is not influenced by this and will open a fresh browser instance and continue to work. However, closing and re-opening the browser (as the above example does) takes a few seconds on an average PC. So if processing speed is important for your application you can split this task in two loops and use iimExit only, for example, every 1000th loop to save time.

'Sample code B
Set iim1= CreateObject ("imacros")
For m = 1 to 5000
   iret = iim1.iimInit()
   For n = 1 to 1000
      iret = iim1.iimPlay ("macro1")
   Next
   iret = iim1.iimExit()
Next

Notes on Running Many Concurrent Instances

Web browsers typically aren't designed for high volume usage such as attempting to run 20 or more concurrent browser instances. A whole host of issues can ensue, from memory leaks to performance degradation and system hangs. This is why we have provided this wiki section to serve as a best practices guide. We encourage you to share your own experiences with our tech support department so that we can continue to spread the knowledge and everyone benefits!

In our testing and experience, CPU power tends to be the primary limiting factor, more so than the amount of RAM in the system. Starting a new browser instance (calling iimOpen) is very CPU intensive, so you want to make sure that you aren't attempting to start multiple browser instances all at the same time or otherwise the system will bog down and may become unresponsive.

The best thing to do is to sequentially launch one instance at a time until all are started, and then commence with playing macros in each instance simultaneously. Of course you should periodically restart the browser instances to avoid memory leaks by shutting them down (with iimExit) and reopening them sequentially again.

Related chapter: How to run iMacros unattended.

Related case study: AlertFox runs iMacros non-stop every day as core part of their unique website transaction monitoring service:

AlertFox runs iMacros Enterprise Edition on the backend (iMacros Enterprise Bundle). The backend consists of Windows 2003 R2 and Windows 2008 servers (both 32-bit and 64-bit). 1000s of browsers are opened and closed all the time. All browsers are controlled by the iMacros Web Scripting interface and iimRunner. The website and test services are created in C++, C# and ASP.NET. The database is MS SQL 2005.

Tip: You can use a simple batch file to remove crashed browser instances. These crashes are caused by the automated browser itself, not iMacros (if you suspect that iMacros causes a crash, please contact our tech support!).

(tinyurl to this FAQ: http://tinyurl.com/6xl8h6)