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 "Editor"
(→Themes) |
|||
Line 159: | Line 159: | ||
=== Themes === | === 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. | Since version 12, the iMacros Editor has introduced '''Default''', '''Dark''' and '''Custom''' code highlighting themes. The themes are reachable from the Settings menu/Themes. | ||
+ | |||
{| | {| | ||
− | |[[File:EditorDarkTheme.png| | + | |[[File:EditorThemes.png|450 px|left|thumb|Choose Themes from the Settings menu.]] || [[File:EditorDarkTheme.png|310 px|thumb|Dark Theme]]||[[File:EditorCustomTheme.png|310 px|thumb|Custom Theme]] |
|} | |} | ||
Revision as of 13:50, 16 August 2017
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.
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.
// 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]); driver.get("http://demo.imacros.net/Automate/TestForm1"); // 'Macro that makes use of Css Selector while recording element = driver.findElement(By.cssSelector("#name")); element.clear(); element.sendKeys("iMacros user"); // 'Drop down element = driver.findElement(By.cssSelector("#food")); element.clear(); element.sendKeys("%Bread and Butter"); element = driver.findElement(By.cssSelector("#drink")); element.clear(); element.sendKeys("%Coke"); // 'Radio button element = driver.findElement(By.cssSelector("#large")); element.click(); element = driver.findElement(By.cssSelector("#dessert")); element.clear(); element.sendKeys("%cranberry"); element = driver.findElement(By.cssSelector("#demo>FIELDSET>OL>LI:nth-of-type(6)>INPUT")); element.click(); // SET !ENCRYPTION NO element = driver.findElement(By.cssSelector("#demo>FIELDSET>OL>LI:nth-of-type(6)>INPUT:nth-of-type(2)")); element.clear(); element.sendKeys("trial"); element = driver.findElement(By.cssSelector("#demo>FIELDSET>OL>LI:nth-of-type(7)>TEXTAREA")); element.clear(); element.sendKeys("Order placed"); // ' element = driver.findElement(By.cssSelector("#demo>FIELDSET:nth-of-type(2)>BUTTON")); element.click(); } catch (Exception e) { System.out.println(e); } finally { driver.close(); driver.quit(); } } }
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.
// 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
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.
Play Macro 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:
- 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.
The editor uses the iMacros Scripting API to play the macro. 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. Since only iMacros Enterprise Edition contains the Scripting API, this feature is disabled in other editions.
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).