Automated UI Tester / Genie



  • Automated UI Tester for Adobe® Action Script® is code named as Genie.

Automated UI Tester is a Flash/Flex automation tool that can record user actions on a SWF file and play them back with high fidelity. With other automation tools, automating Flash applications requires instrumenting them to run inside a wrapper application; but with Genie, it just requires a configuration file and Flash Player. So with Genie, users can automate their production builds easily. Genie currently works on Windows and on Mac OS X.

What you need to setup Genie:

1) Eclipse
2) Genie binary
3) Flash Debug version for IE
4) Any flash application

**Genie does not require instrumentation of you flex app for getting access to flex components unlike most tools. 


Limitations: Only works for Action Script 3 based flex applications.
 
Installation:
Genie setup can be done in 5 minutes flat once the per-requisites are installed.
 
You will need the following prerequisites.
1. Eclipse 
2. Adobe Flash Debugger 

For installation, copy the Genie-binary.zip file from http://sourceforge.net/adobe/genie/wiki/Home/ and follow the steps in Userguide.
Adobe has setup a Genie discussion forum as well, which can be accessed from http://sourceforge.net/adobe/genie/discussion/general/
 
Important:
Once Genie is setup, you will see the below icon on every flash application. If you see the arrow sign in green, then Genie and Eclipse are setup correctly, you can simply click on that green arrow to start recording. On stopping the recording, Genie popups a dialog box which has the java code, which you can copy and use.

 


    



import com.adobe.genie.executor.Genie;
import com.adobe.genie.executor.LogConfig;
import com.adobe.genie.executor.components.GenieButton;
import com.adobe.genie.executor.components.GenieTextInput;
import com.adobe.genie.genieCom.SWFApp;

EXAMPLE:

public class GenieAPIExample {

    //Main method
    public static void main(String[] args) {
        //Instantiate LogConfig class.
        LogConfig l = new LogConfig();
        //Set log folder
        l.setLogFolder("C\\GenieLogs\\");
        //Create a Genie class object.
        Genie g = null;
        try{
      
            Genie.EXIT_ON_FAILURE = true;
            //Initialize Genie class.
            g = Genie.init(l);
          
            //connect to app
            SWFApp app1=g.connectToApp("test");

//Get an object from app and enter text into it         
  GenieDisplayObject host = new GenieDisplayObject("FP^TextInputSkin:::SE^RichEditableText:::CH^TextLine::PX^1::PTR^0::IX^0::ITR^0", app1);
            System.out.println(host.isVisible());
            //host.click();
            new UIKeyBoard().typeText("192.168.1.2");

//Clicking on images in the application

new UIImage().clickImage("F:\\test\\Genie-binary\\Genie\\images\\registerbutton.png", 10);
          
        }catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
        finally
        {
            //Invoke stop() method to perform clean up steps.
            // If stop() does not run then socket connections do not close and JVM does not exit.
            g.stop();
        }

    }
}


Comments

  1. Here is the code for image based testing. using java and genie jars.

    package demoCheck_img;
    import java.util.Iterator;
    import java.util.Set;
    import java.util.concurrent.TimeUnit;
    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.firefox.FirefoxProfile;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;

    import com.adobe.genie.executor.Genie;
    import com.adobe.genie.executor.GenieHelper;
    import com.adobe.genie.executor.LogConfig;
    import com.adobe.genie.executor.components.GenieComponent;
    import com.adobe.genie.executor.uiEvents.UIImage;
    import com.adobe.genie.genieCom.SWFApp;

    public class GenieAPIExample {

    static FirefoxProfile profile = new FirefoxProfile();
    public static WebDriver selenium=new FirefoxDriver(profile);
    static String mainWindowHandle;

    public static void main(String[] args) throws Exception
    {
    launchWebsite();

    //UIGlobal();
    System.out.println("execution over....");
    }
    public static void launchWebsite() throws Exception
    {
    String baseURL="http://";
    mainWindowHandle =selenium.getWindowHandle();
    System.out.println("main win handle : "+mainWindowHandle);
    selenium.get(baseURL+"/");
    selenium.manage().timeouts().implicitlyWait(2, TimeUnit.MINUTES);
    selenium.manage().window().maximize();
    ((JavascriptExecutor) selenium).executeScript("window.focus();");
    selenium.manage().timeouts().pageLoadTimeout(120000, TimeUnit.MILLISECONDS);
    selenium.findElement(By.xpath(".//*[@id='more-games-link']")).click();
    selenium.findElement(By.xpath(".//*[@id='games-container']/div[22]")).click();
    System.out.println("in clk image");
    try
    {
    GoToGameWindow();
    Thread.sleep(10000);
    System.out.println("after thread");

    if(new UIImage().findImage("C:\\Users\\Administrator\\Desktop\\Ginie_images\\demoplay.png", 10) != null);
    {
    System.out.println("inside if");
    // new UIImage().clickImage("C:\\Users\\Administrator\\Desktop\\Ginie_images\\demoplay.png", 10);
    Thread.sleep(50000);
    new UIImage().clickImage("C:\\Users\\Administrator\\Desktop\\Ginie_images\\play.png", 10);
    }//End of if
    }
    catch(Exception e)
    {
    System.out.println("error : "+e.getMessage());
    }
    System.out.println("done clk image");


    }
    public static void GoToGameWindow()
    {

    Set windowNames = selenium.getWindowHandles();

    Iterator ite = windowNames.iterator();
    while(ite.hasNext())
    {
    String popupHandle=ite.next().toString();
    if(!popupHandle.contains(mainWindowHandle))
    {
    selenium.switchTo().window(popupHandle);
    break;
    }
    }
    }


    }
    }

    ReplyDelete
  2. Here is the code for image based testing. using java and genie jars.

    package demoCheck_img;
    import java.util.Iterator;
    import java.util.Set;
    import java.util.concurrent.TimeUnit;
    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.firefox.FirefoxProfile;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;

    import com.adobe.genie.executor.Genie;
    import com.adobe.genie.executor.GenieHelper;
    import com.adobe.genie.executor.LogConfig;
    import com.adobe.genie.executor.components.GenieComponent;
    import com.adobe.genie.executor.uiEvents.UIImage;
    import com.adobe.genie.genieCom.SWFApp;

    public class GenieAPIExample {

    static FirefoxProfile profile = new FirefoxProfile();
    public static WebDriver selenium=new FirefoxDriver(profile);
    static String mainWindowHandle;

    public static void main(String[] args) throws Exception
    {
    launchWebsite();

    //UIGlobal();
    System.out.println("execution over....");
    }
    public static void launchWebsite() throws Exception
    {
    String baseURL="http://";
    mainWindowHandle =selenium.getWindowHandle();
    System.out.println("main win handle : "+mainWindowHandle);
    selenium.get(baseURL+"/");
    selenium.manage().timeouts().implicitlyWait(2, TimeUnit.MINUTES);
    selenium.manage().window().maximize();
    ((JavascriptExecutor) selenium).executeScript("window.focus();");
    selenium.manage().timeouts().pageLoadTimeout(120000, TimeUnit.MILLISECONDS);
    selenium.findElement(By.xpath(".//*[@id='more-games-link']")).click();
    selenium.findElement(By.xpath(".//*[@id='games-container']/div[22]")).click();
    System.out.println("in clk image");
    try
    {
    GoToGameWindow();
    Thread.sleep(10000);
    System.out.println("after thread");

    if(new UIImage().findImage("C:\\Users\\Administrator\\Desktop\\Ginie_images\\demoplay.png", 10) != null);
    {
    System.out.println("inside if");
    // new UIImage().clickImage("C:\\Users\\Administrator\\Desktop\\Ginie_images\\demoplay.png", 10);
    Thread.sleep(50000);
    new UIImage().clickImage("C:\\Users\\Administrator\\Desktop\\Ginie_images\\play.png", 10);
    }//End of if
    }
    catch(Exception e)
    {
    System.out.println("error : "+e.getMessage());
    }
    System.out.println("done clk image");


    }
    public static void GoToGameWindow()
    {

    Set windowNames = selenium.getWindowHandles();

    Iterator ite = windowNames.iterator();
    while(ite.hasNext())
    {
    String popupHandle=ite.next().toString();
    if(!popupHandle.contains(mainWindowHandle))
    {
    selenium.switchTo().window(popupHandle);
    break;
    }
    }
    }


    }
    }

    ReplyDelete
  3. Thanks for the share. Appreciate that!

    ReplyDelete
  4. Anonymous10/12/14

    Hi, i just wanted some help if you have worked with Genie Flash Automation , i have learn number of things but stuck on clicking dynamically generated components. can you please help me with that, as i have no one to guide me for Genie.
    Thanks & regards

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Hi there! Can anyone help me out with some good websites that have Genie tutorials? I am having a tough time finding one. I am working on a project for which I need to learn the tool.

      Delete
  5. anseril-mi Colleen Simpson download
    serliatorba

    ReplyDelete

Post a Comment

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?