我是flex自动化的新手,有没有可能像我们在selenium ide中的任何web应用程序一样,集成flex monkium wtih selenium ide来记录特定的测试用例?
发布于 2015-10-21 09:15:36
您也可以使用Sikuli来实现闪存的自动化--请检查此链接,以了解flash自动化教程,以便从基本的图文开始
Sikuli Java API为Java程序员提供了基于图像的GUI自动化功能。它是创建的,并将积极维护bySikuli实验室。创建这个API是为了响应许多Sikuli用户的愿望,即直接在Java程序中使用Sikuli脚本的功能,而不是编写Jython脚本。这个新的Java库有一个重新设计的API,并包含了一些在原始Sikuli脚本中不可用的新函数,例如匹配颜色、处理事件和查找几何模式(如矩形按钮)的能力。您还可以从:AuYVB4ZjJNM3h0ZlE/view?usp=共享下载此eclipse项目。
步骤:
守则是:
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;
}
}
}
https://stackoverflow.com/questions/33252116
复制相似问题