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