安装sikuli,安装完成之后,安装目录在C:\Program Files,将 安装文件复制到c盘下
配置环境变量
安装eclipse,将selenium的java版本的jar包,添加到你是使用的工程里面
在sikuli-ide下面有一个sikuli_script.jar,将它添加到你使用的工程里面
在程序里面添加上用户图片保存的目录,这一点很重要,否则会提示图片找不到
具体程序如下
package com.client.pmj;
import java.util.concurrent.TimeUnit;
import org.apache.commons.jxpath.ri.compiler.Path;
import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
import org.openqa.selenium.*;
import org.openqa.selenium.WebDriver.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.lift.find.ImageFinder;
import org.python.antlr.PythonParser.if_stmt_return;
import org.python.modules.thread.thread;
import org.sikuli.script.*;
public class Client {
	public static void main(String[] args) {
		System.out.println("helloworld");
		System.out.println("hello world!");
		WebDriver driver = new FirefoxDriver();
		String base_url = "http://www.cxxxxn.com/";
		driver.get(base_url+"sign_in");
		driver.manage().window().maximize();
		driver.findElement(By.id("mail")).clear();
		driver.findElement(By.id("mail")).sendKeys("account");
		driver.findElement(By.id("pwd")).clear();
		driver.findElement(By.id("pwd")).sendKeys("password");
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		driver.findElement(By.cssSelector("button.btn-grey.btn-regular")).click();
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
		WebElement step_1 = driver.findElement(By.id("submenu")).findElement(By.tagName("a"));
		step_1.click();
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//测试flash上传插件模块
		ImageLocator  p = new ImageLocator();
		String[] path = p.getImagePath();
		ImageLocator.addImagePath("E:\\atuo");//添加用户保存图片的目录
		path = p.getImagePath();
		System.out.println(path.length);
		Screen s = new Screen();
		try {
			s.click("app.png");
		} catch (FindFailed e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			Thread.sleep(6000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		driver.quit();
		
		
	}
}Windows 7 32 上 selenium 2+sikuli解决swfupload类型上传插件,布布扣,bubuko.com
Windows 7 32 上 selenium 2+sikuli解决swfupload类型上传插件
原文地址:http://my.oschina.net/u/938257/blog/288450