selenium webdriver java处理上传
2014-09-06 20:09
471 查看
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 使用python脚本处理SWFupload 文件上传
- java selenium webdriver处理JS操作窗口滚动条
- selenium(webdriver)学习笔记6--Alert/Confirm/Prompt的处理(Java版)
- ruby webdriver处理flash类型的图片上传
- selenium webdriver之eclipse java开发环境搭建
- WebDriver(Selenium2) 常见异常及处理方法
- Selenium WebDriver如何处理单选框和多选框
- Selenium Webdriver java
- selenium webdriver (Java)第一弹
- selenium-webdriver(python) (十三) -- cookie处理
- Selenium-Webdriver(python) (十一) --- 文件上传
- Selenium Webdriver 处理隐藏元素的问题
- selenium webdriver之(1).eclipse java开发环境搭建
- selenium webdriver学习(七)------------如何处理alert、confirm、prompt对话框
- selenium webdriver 环境搭建--java
- Selenium WebDriver 弹窗,Frame, 元素处理
- selenium webdriver 不识别showModalDialog()的处理方案
- selenium webdriver学习(十五)------------如何处理FirefoxProfile
- selenium webdriver处理alert、confirm、prompt
- selenium webdriver之eclipse java开发环境搭建