面对org.openqa.selenium.InvalidArgumentException:无效参数:找不到文件异常

问题描述 投票:0回答:1

在 java selenium 中使用 sendkeys 上传文件时会抛出错误 org.openqa.selenium.InvalidArgumentException:无效参数:找不到文件:C:\Users\VK32827\Updated RCL Project esearch-gtf-RLC\DataFilesToUpload\MarketReaserch34.jpeg (会话信息:chrome=122.0.6261.57) 构建信息:版本:'4.0.0-alpha-5',修订版:'b3a0d621cc' 系统信息:主机:'H21NGFFI13P0149',ip:'10.167.228.161',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'17.0.6 ' 驱动程序信息:org.openqa.selenium.remote.RemoteWebDriver

尝试获取文件的绝对路径,也尝试直接在发送键中传递路径,但它不起作用。

file-upload filenotfoundexception
1个回答
0
投票

我遇到了类似的问题,并使用基本路径进行诊断,例如 C: emp ile.txt,在 Java Selenium 中为“C:\\temp\\file.txt” 也就是4倍\

我的代码最终是, driver.findElement(By.xpath("/html/body/modal/ngx-smart-modal/div/div/div/div/div[2]/upload-file/form/div[1]/div/div/ span[2]/input")).sendKeys("C:\Development\Utilities\Automatic-Testing\SmokeTest\Files\Email.msg");

© www.soinside.com 2019 - 2024. All rights reserved.