首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >flex与硒的集成

flex与硒的集成
EN

Stack Overflow用户
提问于 2015-10-21 06:08:53
回答 1查看 1.1K关注 0票数 1

我是flex自动化的新手,有没有可能像我们在selenium ide中的任何web应用程序一样,集成flex monkium wtih selenium ide来记录特定的测试用例?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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项目。

步骤:

  1. 打开Eclipse创建一个新项目下载Selenium绑定下载Sukuli JAR右键单击项目Open New>Class 右键单击“打开构建Path>Configure构建路径开放库”选项卡单击“添加外部Jars”按钮,添加以下导入:导入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;在类@BeforeClass公共静态空setUp()中添加Selenium和Java绑定粘贴下面的代码,引发异常{ wd =新FirefoxDriver();wd.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS); } @Test public void TestCase1()在公共void tearDown() {wd.quit()之后抛出InterruptedException {}@;}公共静态布尔isAlertPresent(FirefoxDriver wd) { try { wd.switchTo().alert();返回true;} catch (NoAlertPresentException e) {返回false}; }
  2. 在浏览器“http://www.terrence.com/flash/calculator.html”中打开Flash计算器链接
  3. 以所需的数量和操作(如1.png、2.png、equal.png和multiply.png等)为例,您可以使用剪切机工具实用程序实现此目的,其预装在Win 7或更高版本中。 就像这样
  4. 现在创建以图像路径为字符串的函数,然后单击该图像。

守则是:

代码语言:javascript
运行
复制
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");
    }

您的最终代码是:

代码语言:javascript
运行
复制
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;
        }
    }


}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33252116

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档