Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法使用selenium将文件从C:下载移动到其他位置_Java_Eclipse_Selenium_Automation - Fatal编程技术网

Java 无法使用selenium将文件从C:下载移动到其他位置

Java 无法使用selenium将文件从C:下载移动到其他位置,java,eclipse,selenium,automation,Java,Eclipse,Selenium,Automation,我现在正在使用selenium下载一个文件,它已保存在路径C:Downloads中,但我希望它保存在我喜欢保存的单独路径中 使用selenium,我可以将桌面文件从一个位置移动到我想要的另一个位置,或者我可以在Eclipse中设置一个路径,在执行脚本时下载文件。如果您使用的是Java 7或更新版本,那么您可以使用文件。移动(从、到、CopyOption…选项) 或者使用Selenium(选项): 您可以将下载的值设置为所需位置的默认目录。@AtulKumarSharma:DesiredCapab

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


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

如果您使用的是Java 7或更新版本,那么您可以使用
文件。移动(从、到、CopyOption…选项)

或者使用
Selenium(选项):


您可以将
下载的值设置为所需位置的默认目录。

@AtulKumarSharma:DesiredCapabilities已弃用(您的解决方案链接)
Files.move(Paths.get("C:\\Downloads\\Kumar.txt"), Paths.get("Full new file path location"));
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);
}