本文介绍了Flex Monkium 与 selenium ide 的集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 flex 自动化的新手,是否有任何可能的方法将 flex Monkium 与 selenium ide 集成来记录特定的测试用例,就像我们可以对 selenium ide 中的任何 Web 应用程序做的那样

解决方案

您也可以使用 Sikuli 进行 Flash 自动化 请检查此链接以获取 Flash 自动化教程以从基本的 教程

Sikuli API for Java 为 Java 程序员提供基于图像的 GUI 自动化功能.它由 Sikuli Lab 创建并将积极维护.制作这个 API 的努力是对许多 Sikuli 用户希望直接在他们的 Java 程序中使用 Sikuli Script 的功能,而不是编写 Jython 脚本的回应.这个新的 Java 库具有重新设计的 API,并包含原始 Sikuli 脚本中不可用的几个新功能,例如匹配颜色、处理事件和查找几何图案(如矩形按钮)的能力.您还可以从以下位置下载此 Eclipse 项目:https://drive.google.com/file/d/0B09BIsDTY_AuYVB4ZjJNM3h0ZlE/view?usp=共享

步骤:

  1. 打开 Eclipse IDE创建一个新项目下载硒绑定下载 Sukuli JAR右键单击您的项目打开新建>类

    右键单击您的项目打开构建路径>配置构建路径打开库选项卡单击添加外部罐子按钮添加以下导入导入 java.io.File;导入 java.util.concurrent.TimeUnit;导入 org.junit.After;导入 org.junit.BeforeClass;进口org.junit.Test;导入 org.openqa.selenium.NoAlertPresentException;导入 org.openqa.selenium.firefox.FirefoxDriver;进口org.sikuli.api.*;导入 org.sikuli.api.robot.Mouse;进口org.sikuli.api.robot.desktop.DesktopMouse;添加 Selenium 和 Java 绑定将以下代码粘贴到您的班级中@课前public static void setUp() 抛出异常 {wd = 新的 FirefoxDriver();wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

    }

    @Testpublic void TestCase1() 抛出 InterruptedException {}@后公共无效撕裂(){wd.quit();}public static boolean isAlertPresent(FirefoxDriver wd) {尝试 {wd.switchTo().alert();返回真;} catch (NoAlertPresentException e) {返回假;}

    }

  2. 在浏览器中打开 Flash 计算器链接http://www.terrence.com/flash/calculator.html >

  3. 拍摄所需数量和操作的小图像,例如 1.png,2.png, equal.png 和 multiply.png 等,你可以使用截图工具实用程序为此,它预装在 Win 7 或更高版本中

    喜欢这些

  4. 现在创建以图像路径为字符串的函数并单击在那张照片上

代码是:

public void click_Image(String img){s = 新桌面屏幕区域();target = new ImageTarget(new File(img));r = s.find(目标);//创建鼠标对象鼠标 = 新桌面鼠标();//使用鼠标对象点击目标区域的中心mouse.click(r.getCenter());}现在在您的测试用例中添加以下代码,首先通过 Web 驱动程序导航到 URL,然后单击您创建的示例代码的图像@测试public void register() 抛出 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");}

您的最终代码将是:

import java.io.File;导入 java.util.concurrent.TimeUnit;导入 org.junit.After;导入 org.junit.BeforeClass;导入 org.junit.Test;导入 org.openqa.selenium.NoAlertPresentException;导入 org.openqa.selenium.firefox.FirefoxDriver;导入 org.sikuli.api.*;导入 org.sikuli.api.robot.Mouse;导入 org.sikuli.api.robot.desktop.DesktopMouse;公共类 testAutomation {公共静态 FirefoxDriver wd;屏幕区域;目标目标;屏幕区域 r;//创建鼠标对象鼠标鼠标;public void click_Image(String img){s = 新桌面屏幕区域();target = new ImageTarget(new File(img));r = s.find(目标);//创建鼠标对象鼠标 = 新桌面鼠标();//使用鼠标对象点击目标区域的中心mouse.click(r.getCenter());}@课前public static void setUp() 抛出异常 {wd = 新的 FirefoxDriver();wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);}@测试public void register() 抛出 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");}@后公共无效撕裂(){wd.quit();}public static boolean isAlertPresent(FirefoxDriver wd) {尝试 {wd.switchTo().alert();返回真;} catch (NoAlertPresentException e) {返回假;}}}

I am newbie for flex automation , is there any possible way to integrate flex monkium wtih selenium ide to record particular test cases as we can do for any web application in selenium ide

解决方案

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 utilityfor this purpose its pre-installed in Win 7 or greater

    Like These

  4. Now Create function which takes path of image as string and clickon 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;
        }
    }


}

这篇关于Flex Monkium 与 selenium ide 的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 21:16