From iMacros
Jump to: navigation, search

The iMacros Editor (iMacrosEditor.exe) was designed specially to edit iMacros macros, but it can be used to edit any text file, including batch files, VBS and JS scripts, XML files, etc. The iMacros Editor is able to recognize these languages and highlight their syntax accordingly. The iMacros Editor is associated to the *.iim files so by right clicking on any .iim file and choosing Edit, the macro is open in the iMacros Editor. This is also the case from any "edit action" in iMacros Browser or iMacros for IE.

The iMacros Editor offers more than just highlighting the iMacros syntax. The Editor makes it much easy to edit the iMacros macros. Testing parts of the macro being edited can also be done directly from the editor. The editor also has the ability to export recorded macros to Selenium WebDriver Java code.

The iMacros Editor offers more than just highlighting iMacros syntax.

Editor Sidebar


The most used functions are always at hand in the sidebar tools panel.
You can easily open new file, edit existing one or save changes to a file via the sidebar buttons.
The tool-tips give information about the button's shortcuts:
New File (CTRL + N)
Open File (CTRL + O)
Save File (CTRL + S)
Play Macro (F5)
Click on the Play button executes the macro open in the current editor tab. The default browser for the macros execution is the iMacros Browser. Under the menu Play/Play in... you can set a different browser having the choice between Internet Explorer, Firefox and Chrome.
The editor sidebar makes also easy the generation of Selenium WebDriver Java code, VB scripts, CSharp and JavaScript code from a macro file.

Export Macro

Once a macro is open in the editor, you can export it completely or partially to be played either by iMacros Scripting API, or through the Selenium WebDriver.

Export to Selenium WebDriver Java code

Now you can profit from the iMacros powerful recorder and export the recorded macro to Selenium WebDriver Java code (QA automation) using the iMacros Editor. Use any flavor of iMacros (Chrome, Firefox, Internet Explorer, or iMacros Browser) to record the elements on a webpage and export the commands to Java Selenium code directly from the iMacros Editor.

Whether you decide to export the complete macro or only a selection of it, when you choose Selenium WebDriver option in the Export menu, a new file will be created with a complete snippet of code like the one below, ready to be inserted in your project.

The easiest way to export is to use the the Se-J button from the sidebar.

Export recorded iMacros macros to Selenium WebDriver Java code.
// WebDriver java snippet for Selenium generated by iMacros Editor
package Imacros;

import java.util.*;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.*;
import org.openqa.selenium.chrome.ChromeDriver;

public class FromiMacros {

	public static void main(String[] args) {
		// Please set the correct path to your Chromedriver.exe file
		System.setProperty("webdriver.chrome.driver", "\\Chromedriver.exe");
		WebDriver driver = new ChromeDriver();

		try {
			List<WebElement> frames;
			Set<String> tabs;
			WebElement element;
			// VERSION BUILD=11.5.497.9113
			tabs = driver.getWindowHandles();
			driver.switchTo().window(tabs.toArray(new String[0])[0]);
			// 'Macro that makes use of Css Selector while recording
			element = driver.findElement(By.cssSelector("#name"));
			element.sendKeys("iMacros user");
			// 'Drop down
			element = driver.findElement(By.cssSelector("#food"));
			element.sendKeys("%Bread and Butter");
			element = driver.findElement(By.cssSelector("#drink"));
			// 'Radio button
			element = driver.findElement(By.cssSelector("#large"));
			element = driver.findElement(By.cssSelector("#dessert"));
			element = driver.findElement(By.cssSelector("#demo>FIELDSET>OL>LI:nth-of-type(6)>INPUT"));
			element = driver.findElement(By.cssSelector("#demo>FIELDSET>OL>LI:nth-of-type(6)>INPUT:nth-of-type(2)"));
			element = driver.findElement(By.cssSelector("#demo>FIELDSET>OL>LI:nth-of-type(7)>TEXTAREA"));
			element.sendKeys("Order placed");
			// '
			element = driver.findElement(By.cssSelector("#demo>FIELDSET:nth-of-type(2)>BUTTON"));

		} catch (Exception e) {
		} finally {

However, there are times when you only need to append a few lines to your class or method. In this case, the Export to Clipboard menu item in the Edit menu will put only the required lines of code in the clipboard which you can then paste into your file.

In both cases, the generated code works best when the macro is recorded in the same browser which is going to be used by the WebDriver.

Export to Scripting Interface code

The iMacros Editor can also generate a snippet of C#, JavaScript, or VBScript code which embeds the current selected macro code and uses iMacros Scripting API. The example below shows the C# generated code from a partial selection of FillForm.iim.

The Editor generates C#, JavaScript or VBScript code for direct use with the iimPlayCode command.

// C# snippet generated by iMacros Editor.
// See http://wiki.imacros.net/Web_Scripting for details on how to use the iMacros Scripting Interface.

// iMacros.AppClass iim = new iMacros.AppClass();
// iMacros.Status status = iim.iimOpen("", true, timeout);
StringBuilder macro = new StringBuilder();
macro.AppendLine(@"URL GOTO=http://demo.imacros.net/Automate/TestForm1");
macro.AppendLine(@"'We use quotation marks for a content with spaces");
macro.AppendLine(@"TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:name CONTENT=""iMacros User""");
macro.AppendLine(@"'Selecting a drop down");
macro.AppendLine(@"TAG POS=1 TYPE=SELECT ATTR=NAME:food CONTENT=%French<SP>Fries");
macro.AppendLine(@"TAG POS=1 TYPE=SELECT ATTR=NAME:drink CONTENT=%Coke");
macro.AppendLine(@"'Selecting a radio button");
macro.AppendLine(@"TAG POS=2 TYPE=INPUT:RADIO ATTR=NAME:drinksize");
string macroCode = macro.ToString();
// status = iim.iimPlayCode(macroCode, timeout);

Uncomment the code lines which creates the iMacros object

iMacros.AppClass iim = new iMacros.AppClass();
iMacros.Status status = iim.iimOpen("", true, timeout);

and call the scripting interface methods

status = iim.iimPlayCode(macroCode, timeout);

to have a complete working program in the chosen language.

See iimOpen for more details on how to change the browser and browser options in the generated code.

Macro Code Highlighting Themes


Since version 12, the iMacros Editor has introduced Default, Dark and Custom code highlighting themes. The themes are reachable from the Settings menu/Themes.

Choose Themes from the Settings menu.
Dark Theme
Custom Theme

Custom Code Highlighting

You can find the iMacros Code Color Styler under Settings menu/Themes/Customize for/Macro files (.iim). The dialog allows you to set the highlighting colors for the iMacros code. The settings are saved in an xml file that can be transferred and used on other iMacros installations.

Open the iMacros Code Color Styler under Settings menu/Themes/Customize for/iMacros Files (.iim)
iMacros Code Color Styler
The XML file with the color settings (in ARGB format) for the macro code

The Path of the XML file is C:\\Users\username\AppData\Roaming\Ipswitch\iMacros Highlight\MacroColors.xml. If you want to revert changes made in the files, you can get again the files from the Folder 'Original Files'.

Customizing the syntax highlighting rules is also possible for VBScript, JavaScript, C#, Java and XML files by modifying the XML Syntax Highlighting Definition files (.xshd) directly. You can open them in the iMacros Editor from the Settings menu/Themes/Customize for/...


In the .xshd files you can set the highlighting styles for the VBScript, JavaScript, Java, C# or XML file code. Find the source tag or keyword that you wish to set a highlighting style for. You can change, for example, the keyword color by specifying color="#9696FF. In the <Environment> tag, you can change the default font and tab page backround color(bgcolor="#219CA5" or bgcolor="White"). To pic a color visit the following link: https://www.w3schools.com/colors/colors_picker.asp Make sure that the input values are valid (no missing or wrong digits), otherwise an exception message will be triggered and the file will be not highlighted. Finally, save your changes without renaming the file or changing its path.

Play Macro Selection

The Play menu. Choose "Play in..." to select another browser to play the macro or selection.

In the Play menu you'll not only find the option to play the complete macro that is currently open in the editor, but also fragments of it. The editor sends the macro or macro lines to the running iMacros Browser (or iMacros Sidebar for IE) to be played via iMacros Scripting API.

Please notice these few remarks about the play feature:

  • The editor uses the iMacros Scripting API to play the macro. Since only iMacros Enterprise Edition contains the Scripting API, this feature is disabled in other editions. Behind the scenes, iimOpen (<browser>, false) is called to connect to the existing iMacros browser and iimPlayCode is used to send the code from the editor to iMacros.
  • If no text is selected on the editor, the line currently under the cursor is played.
  • The editor sends complete lines to iMacros, even if the selection contains only a piece of a line.
  • Play from Here plays all lines from the cursor to the end of the macro.
  • Choose the submenu Play in... another browser like IE, Fx, or Cr where the macro or macro fragment will be played.
  • Play in IE is checked by default if the editor was started from iMacros for IE, via one of the "edit actions" in the iMacros sidebar.
  • The editor plays the macro in the currently open browser. If an open browser is not found, a new browser window is created to play the macro.
  • After playing the macro, the browser window remains open.

Other features

For a comfortable editing of macros containing IMAGESEARCH and IMAGECLICK commands, the editor shows thumbnails of the images referenced in these commands. When you hover the mouse over the name of an image file, it pops-up a small thumbnail preview of that image.

You can insert pre-defined command and variable templates directly into your macro using the Insert menu. The parameters can be adjusted after inserting the template. Additionally in Insert menu, you'll find the password encryption/decryption tool which recognizes an encrypted password and can decrypt it, given the master key is entered. The password tool can also be invoked using the shortcut key combinations Ctrl+E (for encryption) and Ctrl+D (for decryption).

The Insert menu. Insert pre-defined commands in your macro.