flex monkium integration with selenium ide

人盡茶涼 提交于 2019-12-02 04:44:14

You can also use Sikuli for automation of flash Please check this link for Flash automation Tutorial to start with basic Turtorial

Sikuli API for Java provides image-based GUI automation functionalities to Java programmers. It is created and will be actively maintained bySikuli Lab. The effort of making this API is a response to the desire of many Sikuli users to use Sikuli Script's functionalities directly in their Java programs, rather than writing Jython scripts. This new Java library has a re-designed API and includes several new functions that were not available in the original Sikuli Script, such as the abilities to match colors, handle events, and find geometric patterns such as rectangular buttons. You can also download this eclipse project from : https://drive.google.com/file/d/0B09BIsDTY_AuYVB4ZjJNM3h0ZlE/view?usp=sharing

Steps:

  1. Open Eclipse IDE Create a new Project Download Selenium Bindings Download Sukuli JAR Right click on you project Open New>Class

    Right click on you project
    
    
    
    
    
    Open Build Path>Configure Build Path
    
    
    Open Libraries Tab
    
    Click add External Jars button
    Add Following Imports 
    
    import java.io.File; import java.util.concurrent.TimeUnit;
    
    
    import org.junit.After; import org.junit.BeforeClass; import
    org.junit.Test; import org.openqa.selenium.NoAlertPresentException;
    import org.openqa.selenium.firefox.FirefoxDriver; import
    org.sikuli.api.*; import org.sikuli.api.robot.Mouse; import
    org.sikuli.api.robot.desktop.DesktopMouse;
    
    
        Add Selenium and Java Bindings 
        Paste Following code in Your Class
    
    @BeforeClass
    public static void setUp() throws Exception {
        wd = new FirefoxDriver();
        wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    

    }

    @Test
    public void TestCase1() throws InterruptedException {
    
    }
    
    @After
    public void tearDown() {
        wd.quit();
    }
    
    public static boolean isAlertPresent(FirefoxDriver wd) {
        try {
            wd.switchTo().alert();
            return true;
        } catch (NoAlertPresentException e) {
            return false;
        }
    

    }

  2. Open Flash Calculator Link in Browser “http://www.terrence.com/flash/calculator.html

  3. Take small images of required number and operations like 1.png,2.png , equal.png and multiply.png etc. you can use snipping tool utility for this purpose its pre-installed in Win 7 or greater

    Like These

  4. Now Create function which takes path of image as string and click on that image

Code is:

public void click_Image(String img)
{
  s = new DesktopScreenRegion();
 target = new ImageTarget(new File(img));
  r = s.find(target);


 // Create a mouse object
  mouse = new DesktopMouse();
 // Use the mouse object to click on the center of the target region
 mouse.click(r.getCenter()); 
}

Now add Following code in your test case first navigate to URL by web driver and then click by images which you created example code is 



 @Test
    public void register() throws InterruptedException {
     wd.get("http://www.terrence.com/flash/calculator.html");
     click_Image("IMG\\1.png");
     click_Image("IMG\\0.png");
     click_Image("IMG\\plus.png");
     click_Image("IMG\\2.png");
     click_Image("IMG\\equal.png");
    }

Your final code would be:

import java.io.File;
import java.util.concurrent.TimeUnit;


import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.sikuli.api.*;
import org.sikuli.api.robot.Mouse;
import org.sikuli.api.robot.desktop.DesktopMouse;


public class testAutomation {
public static FirefoxDriver wd;


ScreenRegion s;
Target target ;
ScreenRegion r; 


// Create a mouse object
Mouse mouse ;


public void click_Image(String img)
{
  s = new DesktopScreenRegion();
 target = new ImageTarget(new File(img));
  r = s.find(target);


 // Create a mouse object
  mouse = new DesktopMouse();
 // Use the mouse object to click on the center of the target region
 mouse.click(r.getCenter()); 
}
    @BeforeClass
    public static void setUp() throws Exception {
        wd = new FirefoxDriver();
        wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    }

    @Test
    public void register() throws InterruptedException {
     wd.get("http://www.terrence.com/flash/calculator.html");
     click_Image("IMG\\1.png");
     click_Image("IMG\\0.png");
     click_Image("IMG\\plus.png");
     click_Image("IMG\\2.png");
     click_Image("IMG\\equal.png");
    }

    @After
    public void tearDown() {
        wd.quit();
    }

    public static boolean isAlertPresent(FirefoxDriver wd) {
        try {
            wd.switchTo().alert();
            return true;
        } catch (NoAlertPresentException e) {
            return false;
        }
    }


}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!