我是Flex自动化的新手,是否有可能像在硒中的任何Web应用程序一样,将硒与ide集成在一起来记录特定的测试用例?

最佳答案

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

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

脚步:


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

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;
    }


}
在浏览器中打开Flash计算器链接
http://www.terrence.com/flash/calculator.html
拍摄所需数量和操作的小图像,例如1.png,2.png
,equal.png和multiple.png等。您可以使用截图工具实用程序
为此,它已预装在Win 7或更高版本中

像这些
现在创建将图像路径作为字符串的函数,然后单击
在那个图像上


代码是:

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");
    }


您的最终代码为:

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;
        }
    }


}

关于apache-flex - Flex铵与 Selenium ionic 的整合,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33252116/

10-13 05:11