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"
Line 109: | Line 109: | ||
== Play Macro Selection == | == Play Macro Selection == | ||
− | + | [[File:EditorPlay.png|300px|left|thumb|The Play menu. The same selection is available via right-click. Choose "Play in..." to select another browser to play the macro or selection.]] | |
− | + | In the '''Play''' menu you find not only the option to play the complete macro 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 [[Web Scripting|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. | * 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. | * '''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. | * '''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. | * 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 the | + | * After playing the macro, the browser window remains open. |
− | |||
− | |||
+ | The editor uses the [[Web Scripting|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 [http://imacros.net/store/compare-versions iMacros Enterprise Edition] contains the Scripting API, this feature is disabled in other editions. | ||
== Other features == | == Other features == |
Revision as of 15:27, 11 October 2016
You find now in the iMacros distribution folder the iMacros Editor (iMacrosEditor.exe) which was designed specially to edit iMacros macros. But you can use it for any text file, including batch files, vbs and javascripts, XML files, etc. The iMacros Editor is able to recognize these languages and highlight their syntax accordingly. The iMacros Editor is now also 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 if you choose any "edit action" in iMacros Browser or IE Plugin.
Export
Export to Selenium WebDriver code
Now one can use iMacros powerful recorder and export the recorded macro to Selenium WebDriver Java code (QA automation) using iMacros Editor. Use any iMacros (for Chrome, Firefox, Internet Explorer, or iMacros Browser) to record elements on a webpage and export the commands to Java Selenium code directly from the iMacros Editor.
// 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(); } } }
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 define the iMacros object and call the scripting interface methods to have a complete working program in the chosen laguage.
See iimOpen for more details on how to change the browser and browser options in the generated code.
Play Macro Selection
In the Play menu you find not only the option to play the complete macro 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
The editor shows thumbnails of the images which you use in IMAGESEARCH and IMAGECLICK 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. Adjust the parameters after inserting the template. You find additionally in this menu 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).