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
Selenium
iMacros 11.5 Offers Export to Selenium WebDriever Java Code
With the release of iMacros 11.5, you can profit from the iMacros powerful recorder and convert your macro code to Java Selenium WebDriver (QA automation) code directly from the iMacros Editor. Web testers should be happy to know that they can use any flavor of iMacros (for Chrome, Firefox, or Internet Explorer) to record elements on a webpage and then easily export the commands to Java Selenium code using this new feature of the iMacros Editor. See Features Comparison to check which iMacros editions support the new Selenium feature.
Whether you decide to export the complete macro or only a selection of it, when you choose the 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 J button from the toolbar.
// 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.