码迷,mamicode.com
首页 > 编程语言 > 详细

selenium webdriver java处理上传

时间:2014-09-06 21:10:43      阅读:431      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   java   ar   文件   div   cti   

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");

                }

            }

        }

    }

 

 

selenium webdriver java处理上传

标签:style   blog   color   os   java   ar   文件   div   cti   

原文地址:http://www.cnblogs.com/zhangminjie/p/3959756.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!