MAC 上 selenium 2+sikuli解决swfupload类型上传插件
[*]环境:MAC 10.9.3安装有Eclipse,在eclispe 上安装selenium jar包(在JAVA IDE中使用selenium)
[*]在http://www.sikuli.org/downloadrc3.html 下载Sikuli X-1.0rc3 (r930) osx-10.6.dmg
[*]下载完成后,点击Sikuli X-1.0rc3 (r930) osx-10.6.dmg完成安装
[*]找到Sikuli.app中的sikuli-script.jar
[*]在eclipse里面,添加sikuli-script.jar
[*]在java程序里面加上
import org.sikuli.script.*;
接下来就可以写程序了。。。。。
下面是一个例子
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();
}
}
}
支持分享
页:
[1]