The following examples are based on the use of the WhatsUp Gold Server (WUG) of Ipswitch Inc.
1 Handling Dynamic IDs
Normally, the automatically generated macro files work the way they are recorded by iMacros. However, sometimes an error occurs during replay due to a “tricky” or dynamic web page. In this case, editing the macro manually will solve the problem.
1.1 Dynamic Web Pages
Some web sites, e. g. WUG, are generated dynamically each time the page is loaded. Some dynamic web pages may use session IDs, which are unique numbers changing each time you visit a page. During recording with iMacros, the session or dynamic IDs are written into the macro as part of the TAG command. If you try to replay a macro with session IDs in a different browser session, iMacros will not find the exact link and will return an error.
1.2 Solution: Use Wildcards
There is an easy workaround with iMacros. The solution is to replace the dynamic (usually numeric) part of the ID’s value in a TAG command with the * wildcard symbol. The wildcard causes iMacros to accept any character where the * is placed.
The following TAG command is a click on the Save button in WUG and has a session ID with dynamic values (numbers):
If you replace the numbers of the ID with the * wildcard, the macro will be successfully executed in every browser session:
1.4 Use Other Attributes to Identify the Element
Alternatively, you can use any other available attribute to specify the element, e.g. the CLASS or the TXT attribute, or both:
2 Using the Index Tree for Navigation rather than the Page URL
2.1 WUG Page Navigation
While recording, iMacros will automatically insert at the start of the macro the command URL GOTO=X. In case of recording on WUG, this way of navigation to a web page is not advantageous since each time it executes it will trigger a login to the system, which is time consuming.
2.2 Solution: Use WUG Index and iMacros TAG command for Navigation
Instead of using URL GOTO=X, you can use the TAG command created while recording a click on the WUG Index tree tab:
One problem here is that iMacros does not have any information on whether the Index tree is currently expanded or not. The TAG command will simply click on a certain item from the Index and will expand it if it is collapsed and vice versa.
Since iMacros is designed as a descriptive language like HTML, it does not contain conditional statements. We can use any script or programming language to check if the index tree is expanded or not. For this purpose, we are using iMacros with VBScript in the following procedure:
This procedure is looking for a certain item from the Index. If the item can be found, then this means the tree has been expanded already. Otherwise, it has to be expanded using a TAG command.
Example: If we want to navigate to Network Performance Monitor -> Devices & Discovery -> Devices and Groups, we will call the procedure in the VB script as follows:
NavigateTree “Network Performance Monitor”, “Devices & Discovery”
NavigateTree “Devices & Discovery”, “Devices and Groups”
3 Closing all other Tabs in WUG
3.1 Tabbed Web Sites
Navigating to different pages in WUG will open them in page tabs. These page tabs are part of the web application, and should not be confused with tabs opened by the web browser. The tabbed web site contains elements, e.g. menus, with the same ID attribute. This can cause the macro to open a menu on a different tab than the intended one. You need to close all page tabs except the current one, so they will not interfere with the executed macro.
3.2 Solution: Close other Tabs
Before opening any menu, close all other web page tabs by adding the following code to your macro:
After WUG login and before starting the first test case step, run the following macro to ensure that you start the test case always from the same initial state, closing all tabs and viewing the Index tree:
4 Using Relative Positioning
4.1 Element Position
The position of the elements in the WUG tables can change in the next browser session depending on the number of elements, e.g. log report messages, that have been displayed. This can cause the macro to fail. It is possible to tag an element relative to its outer element in a nested situation.
4.2 Solution: Relative Positioning
The following macro first tags the table DIV element named User-Passive-Monitor and then looks for the previous occurrence of an image (in this case it is the Options menu icon):
Using relative positioning we can ensure that the macro opens the Options menu of the User-Passive-Monitor and not the options of any other available passive monitor. Otherwise we cannot distinguish between two Options menus.
5 Dealing with Timing Issues
Since the WUG User Interface needs time for the login, to display dialogs, and for some types of “processing request” messages, it is necessary to tune the macro’s behavior in order to avoid runtime errors and other timing issues.
5.1 Use the WAIT Command
Using the WAIT SECONDS=X command will specify the time before continuing replay with the next macro command.
5.2 Use the SET !TIMEOUT_STEP Command
It is possible to adjust the wait time by using SET !TIMEOUT_STEP X. The TAG command will wait up to a maximum of !TIMEOUT_STEP seconds, checking every second if the relevant element is loaded. Unlike WAIT, if the element is loaded prior to the timeout expiring, the macro will immediately continue. The default wait time is 6 seconds.
SET !TIMEOUT_STEP 45
5.3 Use IMAGESEARCH
Alternatively, IMAGESEARCH can also be used. This requires some more work during recording, but allows you to avoid any WAIT statements.
6 iMacros Settings
In general, while recording with iMacros on WUG, you do not need to make any changes to the iMacros settings. However, changing some settings can help you investigate problems or edit the recording code.
6.1 Switching between Auto and Expert Recording Mode
Switching between Automatic and Expert Click Mode (iMacros Sidebar > Record tab > Click Mode) can be helpful if you want to manually edit one element’s attributes in a TAG command. In Auto mode, iMacros looks at the different attributes an element has (such as ID, Name, Class, Text, HFEF etc.) and selects the one attribute it thinks fits best. In Expert mode, iMacros does not select just one attribute but creates a TAG command with all attributes of the clicked HTML element. The purpose is to give a quick overview of all the element’s attributes so that the user can edit the TAG command manually and select the attribute (or combination of attributes) that work best.
6.2 Changing the Replay Speed to Trace Problems
You can also change the Replay Speed in the iMacros settings to medium or slow while tracing problems.
7 Recording Tooltips Created with the qTip Plugin
7.1 Extract Custom Attributes
Normally, the tooltips are specified by the title attribute of an element. You can extract the tooltip content with iMacros:
ComputerName=* is the initial immutable part of the tooltip content and is used to specify which tooltip should be extracted.
What Our Customers Say
A Scalable Toolset
To give you some sizing – our website is over 1\4 million lines of code with complex business rules\logic. Our defect rate is well below industry standards through two major releases last year. One of the releases impacted over 40% of site pages...
Cross Browser Testing
Thanks! This solution is killer for our cross platform / cross browser testing! I have a VM setup in VirtualBox, and I pointed all of the paths to the same place on the host, so I have one folder for macros, shared by IE / XP , Firefox XP and Fire...
Testing Flash Apps
Great application, I'm a flash developer and the games I create have to be played 1000's of times before I can submit them officially to test. I spent weeks looking for a suitable test app and have found yours to be fantastic. I have gradually cre...
Intuitive Web Testing
iMacros works great. I implemented it in my product test solution of wireless modems with embedded web pages. It brought the manual test of 10 minutes to an automated test of 90 seconds.
An Extra Employee
We use iMacros Enterprise Edition to manage our online advertising and compile sales information so that we can effectively compute our ROI and make decisions based on it. Integrating the software into our development process has gone very smoothl...
A Suberb Product
Within 5 days since I had ever heard of iMacros, 3 days since I started seriously looking at it, and within 1 day of purchase I have successfully extracted 30 fields across 2 pages from a total of 1265 accounts and generated a concise, accurate da...
First State Bank of Altus