简体   繁体   English

如何使用带有 selenium webdriver 的 Windows 文件资源管理器选择多个文件

[英]How to select many files using Windows file explorer with selenium webdriver

I am automating a UI test where selecting file to upload is involved, I was able to automate the file selection using this solution .我正在自动化 UI 测试,其中涉及选择要上传的文件,我能够使用此解决方案自动化文件选择。

WebElement filepath=driver.findElement(By.id("fileUploadId"));
filepath.sendKeys("C:\\TextFile.txt");

My issue is that I need to select many files to upload, is there a special format I should follow in the path I am sending?我的问题是我需要选择许多要上传的文件,在我发送的路径中是否应该遵循特殊格式? because I tried space-separated paths and it didn't work.因为我尝试了空格分隔的路径,但没有奏效。

To upload multiple files you can construct the character string adding all the absolute path of the files seperated by \\n as follows:上传多个文件,您可以构造添加所有由\\n分隔的文件的绝对路径字符串,如下所示:

WebElement filepath = driver.findElement(By.id("fileUploadId"));
filepath.sendKeys("C:/TextFile1.txt \n C:/TextFile2.txt \n C:/TextFile3.txt");

References参考

You can find a couple of relevant detailed documentations in:您可以在以下位置找到一些相关的详细文档:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows File Explorer中选择多个文件 - How to select multiple files in windows file explorer 如何使用 Selenium Webdriver 和 Internet Explorer 10 处理 Windows 身份验证? - How to handle Windows Authentication with Selenium Webdriver and Internet Explorer 10? 如何使用Selenium Webdriver在Internet Explorer上获取Cookie-C# - How to get cookies on internet explorer using Selenium webdriver - C# 如何使用Selenium WebDriver检查Windows Modal对话框是否存在 - How to check if Windows Modal Dialog is present using Selenium WebDriver Selenium WebDriver 和浏览器选择文件对话框 - Selenium WebDriver and browsers select file dialog 使用Internet Explorer 11的多个Selenium Webdriver实例会相互干扰 - Multiple selenium webdriver instances using Internet Explorer 11 interfere with eachother 如何在资源管理器中选择文件而不创建不必要的窗口? - How to select file in Explorer without creating unnecessary windows? 如何使用带有C#的Selenium WebDriver将数据写入Excel文件? - How to write data into an Excel file using Selenium WebDriver with C#? 如何使用.net中的PhantomJS在Selenium Webdriver中上传文件? - How to upload file in selenium webdriver using PhantomJS in .net? 如何使用 selenium c# webdriver 重命名下载的文件 - How to rename downloaded file using selenium c# webdriver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM