【问题标题】:Unable to move the file from C:downloads to other location using selenium无法使用 selenium 将文件从 C:downloads 移动到其他位置
【发布时间】:2021-08-21 06:03:09
【问题描述】:

我正在使用 selenium 下载一个文件,现在它已保存在路径 C:Downloads 中,但我希望将其保存在我喜欢保存的单独路径中。

我可以使用 selenium 将该桌面文件从一个位置移动到另一个我想要的位置,否则我可以在 Eclipse 本身中设置一个路径,以便在执行脚本时下载文件。

【问题讨论】:

标签: java eclipse selenium automation


【解决方案1】:

如果您使用的是 Java 7 或更新版本,则可以使用Files.move(from, to, CopyOption... options)

Files.move(Paths.get("C:\\Downloads\\Kumar.txt"), Paths.get("Full new file path location"));

或者使用Selenium (Options) :

protected static WebDriver driver;

@Test
public void testSO() throws InterruptedException {
  ChromeOptions options =  new ChromeOptions();
  options.addArguments("download.default_directory = C:/Downloads");
  driver = new ChromeDriver(options);
}

您可以将download.default_directory 的值设置为您想要的位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-05
    • 2022-07-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多