zoukankan      html  css  js  c++  java
  • selenium webdriver java处理上传

    public void uploadFile(String path) {
    
            //File file = new File("C:\jacob-1.18-M2-x64.dll");
    
            // System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());//把DLL加入到系统变量.或者丢到System32下
    
            AutoItX x = new AutoItX();
    
            Locale locale = Locale.getDefault();
    
            String title = "Open";
    
            String browserType = TestCase.DriverManager.browserType;
    
            if (browserType.equals("CHROME")) {
    
                if (locale.getDisplayLanguage().equals("中文")) title = "打开";
    
                if (x.winWaitActive(title, "", 10)) {
    
                    if (x.winExists(title)) {
    
                        x.sleep(500);
    
                        //x.send(path);
    
                        x.controlCommandEditPaste(title, "", "Edit1", path);
    
                        x.controlClick(title, "", "Button1");
    
                    }
    
                }
    
            }
    
            if (browserType.equals("FIREFOX")) {
    
                title = "File Upload";
    
                if (locale.getDisplayLanguage().equals("中文")) title = "文件上传";
    
                if (x.winWaitActive(title, "", 10)) {
    
                    if (x.winExists(title)) {
    
                        x.sleep(500);
    
                        //x.send(path);
    
                        x.controlCommandEditPaste(title, "", "Edit1", path);
    
                        x.controlClick(title, "", "Button1");
    
                    }
    
                }
    
            }
    
            if (browserType.equals("IE")) {
    
                title = "Choose File to Upload";
    
                if (locale.getDisplayLanguage().equals("中文")) title = "选择要加载的文件";
    
                if (x.winWaitActive(title, "", 10)) {
    
                    if (x.winExists(title)) {
    
                        x.sleep(500);
    
                        //x.send(path);
    
                        x.controlCommandEditPaste(title, "", "Edit1", path);
    
                        x.controlClick(title, "", "Button1");
    
                    }
    
                }
    
            }
    
        }
    
     
  • 相关阅读:
    sql 常见错误
    jdbc 回顾
    oracle return code 2112
    cobol COMP-3最后1位
    oracle Lower Upper length substr
    UTF-8 与 BIG-5 转码
    用UltraEdit转换大小写
    oracle substr
    oracle中 char,varchar,varchar2的区别
    oracle 查看16进制
  • 原文地址:https://www.cnblogs.com/zhangminjie/p/3959756.html
Copyright © 2011-2022 走看看