Windows 7 32 上 selenium 2+sikuli解决swfupload类型上传插件

来源:互联网 发布:二维码制作软件下载 编辑:程序博客网 时间:2024/06/04 14:31

摘要 Windows 7 32 上 eclipse+selenium 2+sikuli解决swfupload类型上传插件 公司的电脑是windows 7 32; 测试的产品有网站;还有客户端; 网站上用来解决识别flash 上传插件。selenium 2+sikuli+eclipse 客户端是,PC端应用程序,每一次的回归都我让感到巨累; 为了更高效的工作,so。。。。。。eclipse+sikuli 在MAC环境没有遇到什么困难 但是windows上遇到了好多麻烦。。。。 但是最终还是解决了

  1. 安装sikuli,安装完成之后,安装目录在C:\Program Files,将 安装文件复制到c盘下

  2. 配置环境变量

  3. 安装eclipse,将selenium的java版本的jar包,添加到你是使用的工程里面

  4. 在sikuli-ide下面有一个sikuli_script.jar,将它添加到你使用的工程里面

  5. 在程序里面添加上用户图片保存的目录,这一点很重要,否则会提示图片找不到

  6. 具体程序如下


  7. ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    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();
             
             
        }
     
    }




0 0
原创粉丝点击