java - 在 Jenkins 中,sendKeys(filePath) 间歇性地给 selenium InvalidArgumentException of fileNotFound 尽管文件存在
问题描述
在 selenium + Java 中,我使用 webElement.sendKeys(filePath) 将文件上传到 jenkins 的网页中,这会导致间歇性 InvalidArgumentException 异常,尽管文件在那里。文件位于资源文件夹中的源代码仓库中;
org.openqa.selenium.InvalidArgumentException: invalid argument: File not found :
/blah/blah1/abc.pdf
(Session info: headless chrome=88.0.4324.96)
if (driver instanceof RemoteWebDriver) {
((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector());
}
assertThat(file.exists()).isTrue();
webElement.sendKeys(file.getAbsolutePath());
尽管断言总是通过,但这里 sendKeys 间歇性地给出 InvalidArgumentException。
有人遇到过类似的问题吗?请提供任何解决方案。关于 linux docker 容器的详细信息
os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-1103-azure', java.version:
'11.0.5'
chrome: {chromedriverVersion: 91.0.4472.19
selenium.version :- 3.141.59
解决方案
推荐阅读
- node.js - 如何使用来自电子的 axios 发布图像数组缓冲区?
- ios - 在我让 iPhone 闲置后 Siri Custom Intent 停止工作
- python - 我的 pyttsx3 无法正常工作,因为它没有发出大卫的声音
- spring-boot - 期望代码引发一个可抛出的 spring JUnit
- flutter - 多次播放同一个音频文件 - Audioplayers Flutter
- html - 标题文本不会出现在图像源旁边
- javascript - 如何在javascript中限制图像更改的复选框计数
- python - 我的石头剪刀布游戏中的错误,通过语句后循环不正确
- java - DevOps - Maven: org.apache.maven.lifecycle.LifecycleExecutionException: 未能执行目标 org.apache.maven.plugins:maven-war-plugin:2.6:war
- javascript - JQuery 适用于 OBS 但不适用于浏览器