摘要 Windows 7 32 上 eclipse+selenium 2+sikuli解决swfupload类型上传插件 公司的电脑是windows 7 32; 测试的产品有网站;还有客户端; 网站上用来解决识别flash 上传插件。selenium 2+sikuli+eclipse 客户端是,PC端应用程序,每一次的回归都我让感到巨累; 为了更高效的工作,so。。。。。。eclipse+sikuli 在MAC环境没有遇到什么困难 但是windows上遇到了好多麻烦。。。。 但是最终还是解决了
-
安装sikuli,安装完成之后,安装目录在C:\Program Files,将 安装文件复制到c盘下
-
配置环境变量
-
安装eclipse,将selenium的java版本的jar包,添加到你是使用的工程里面
-
在sikuli-ide下面有一个sikuli_script.jar,将它添加到你使用的工程里面
-
在程序里面添加上用户图片保存的目录,这一点很重要,否则会提示图片找不到
-
具体程序如下
-
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
packagecom.client.pmj;importjava.util.concurrent.TimeUnit;importorg.apache.commons.jxpath.ri.compiler.Path;importorg.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;importorg.openqa.selenium.*;importorg.openqa.selenium.WebDriver.*;importorg.openqa.selenium.firefox.*;importorg.openqa.selenium.lift.find.ImageFinder;importorg.python.antlr.PythonParser.if_stmt_return;importorg.python.modules.thread.thread;importorg.sikuli.script.*;publicclassClient {publicstaticvoidmain(String[] args) {System.out.println("helloworld");System.out.println("hello world!");WebDriver driver =newFirefoxDriver();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 blocke.printStackTrace();}driver.findElement(By.cssSelector("button.btn-grey.btn-regular")).click();try{Thread.sleep(3000);}catch(InterruptedException e) {// TODO Auto-generated catch blocke.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 blocke.printStackTrace();}//测试flash上传插件模块ImageLocator p =newImageLocator();String[] path = p.getImagePath();ImageLocator.addImagePath("E:\\atuo");//添加用户保存图片的目录path = p.getImagePath();System.out.println(path.length);Screen s =newScreen();try{s.click("app.png");}catch(FindFailed e) {// TODO Auto-generated catch blocke.printStackTrace();}try{Thread.sleep(6000);}catch(InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}driver.quit();}}
本文详细介绍了在Windows732环境下,通过eclipse+selenium2+sikuli解决SWF上传插件公司产品的测试过程,包括环境配置、代码实现及解决遇到的问题。

1686

被折叠的 条评论
为什么被折叠?



