Selendroid文件上传/下载

时间:2015-01-23 07:47:01

标签: webdriver selendroid

如何使用Java在Selendroid上执行文件上传和下载?我正在测试网站的移动版本..我使用Selenium webdriver上传和下载,它运行得很好。请给我一个Selendroid上传/下载的解决方案。

public void startDriver() throws InvalidFileFormatException, IOException{ 


    FirefoxProfile profile = new FirefoxProfile();

    String path1 = "C:\\Downloads_sel";
    profile.setPreference("browser.download.folderList", 2);
    profile.setPreference("browser.download.dir", path1);
    System.out.println(path1);
    profile.setPreference("browser.download.alertOnEXEOpen", false);
    // profile.setPreference("browser.helperApps.neverAsksaveToDisk",
    // "application/x-msexcel,application/excel,application/x-excel,application/excel,application/x-excel,application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/pdf,application/xml");
    profile.setPreference(
            "browser.helperApps.neverAsk.saveToDisk",
            "application/msword, application/csv, application/ris, text/csv, image/png, application/pdf, text/html, text/plain, application/zip, application/x-zip, application/x-zip-compressed, application/download, application/octet-stream");
    profile.setPreference("browser.download.manager.showWhenStarting",
            false);
    profile.setPreference("browser.download.manager.focusWhenStarting",
            false);
    profile.setPreference("browser.helperApps.alwaysAsk.force", false);
    profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
    profile.setPreference("browser.download.manager.closeWhenDone", false);
    profile.setPreference("browser.download.manager.showAlertOnComplete",
            false);
    profile.setPreference("browser.download.manager.useWindow", false);
    profile.setPreference("browser.download.manager.showWhenStarting",
            false);
    profile.setPreference(
            "services.sync.prefs.sync.browser.download.manager.showWhenStarting",
            false);
    // ..i commented this line..but it didnt work
    profile.setPreference("pdfjs.disabled", true);       
    driver = new FirefoxDriver(profile);
    driver.manage().window().maximize();
    driver.get(URL1);
    System.out.println("gotURL");

}

这是我在selenium webdriver中执行下载的代码..以及如何在selendroid中执行相同操作

0 个答案:

没有答案