首页 > 代码库 > selenium webdriver 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"); } } } }
selenium webdriver java处理上传
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。