In selenium + Java I am using webElement.sendKeys(filePath) to upload the file in the webpage in jenkins which is causing intermittently InvalidArgumentException exception though file is there. File is located in the source code repo in resources folder ;
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());
Here sendKeys intermittently giving InvalidArgumentException though assertion is passing always.
Anyone has encountered similar problems? Any solution please. Details about linux docker container
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