環境:MAC 10.9.3安裝有Eclipse,在eclispe 上安裝selenium jar包(在JAVA IDE中使用selenium)css
在http://www.sikuli.org/downloadrc3.html 下載Sikuli X-1.0rc3 (r930) osx-10.6.dmg html
下載完成後,點擊Sikuli X-1.0rc3 (r930) osx-10.6.dmg 完成安裝java
4. 找到Sikuli.app中的sikuli-script.jarweb
5. 在eclipse裏面,添加sikuli-script.jarapp
6. 在java程序裏面加上eclipse
import org.sikuli.script.*;網站
7. 接下來就能夠寫程序了。。。。。。url
8. 下面是一個例子
spa
webdriver打開網站,進入上傳頁面,sikuli點擊上傳按鈕firefox
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(); } } }