环境:MAC 10.9.3安装有Eclipse,在eclispe 上安装selenium jar包(在JAVA IDE中使用selenium)
在 下载
下载完成后,点击 完成安装
4. 找到Sikuli.app中的sikuli-script.jar
5. 在eclipse里面,添加sikuli-script.jar
6. 在java程序里面加上
import org.sikuli.script.*;
7. 接下来就可以写程序了。。。。。。
8. 下面是一个例子
webdriver打开网站,进入上传页面,sikuli点击上传按钮
package selenium;import java.util.concurrent.TimeUnit;import org.openqa.selenium.*;import org.openqa.selenium.WebDriver.*;import org.openqa.selenium.firefox.*;import org.sikuli.script.*;public class seleniumClass { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("hello world!"); WebDriver driver = new FirefoxDriver(); String base_url = "http://www.xxxxxx.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(); } Screen s = new Screen(); try { s.doubleClick("select_apk.png"); } catch (FindFailed e) { // TODO Auto-generated catch block e.printStackTrace(); } try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}