zoukankan      html  css  js  c++  java
  • selenium + Java 设置文件默认下载路径

    import java.util.HashMap;
    import java.util.Map;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    import org.openqa.selenium.remote.DesiredCapabilities;

    public class Test {
    public static void main(String[] args) throws InterruptedException {
    //谷歌瀏覽器
    System.setProperty("webdriver.chrome.driver",
    "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");
    DesiredCapabilities caps = setDownloadsPath("D:\\DownLoad");//更改默认下载路径
    WebDriver webDriver = new ChromeDriver(caps);
    }
    /**
    * 设置默认下载路径
    * @param path
    * @return
    */
    public static DesiredCapabilities setDownloadsPath(String path) {
    Map<String, Object> chromePrefs = new HashMap<String, Object>();
    chromePrefs.put("download.default_directory", path);
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("prefs", chromePrefs);
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability(ChromeOptions.CAPABILITY, options);
    return caps;
    }
    }
    ————————————————
    版权声明:本文为CSDN博主「辛勤小王子」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/qq_37917691/article/details/106945429

  • 相关阅读:
    SQLServer之删除索引
    SQLServer之修改索引
    SQLServer之创建辅助XML索引
    SQLServer之创建主XML索引
    SQLServer之创建全文索引
    SQLServer之创建唯一非聚集索引
    SQLServer之创建唯一聚集索引
    SQLServer之创建非聚集索引
    SQLServer之添加聚集索引
    给NSMutableArray添加copy属性就变成了NSArray
  • 原文地址:https://www.cnblogs.com/javalinux/p/14804331.html
Copyright © 2011-2022 走看看