0

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 
5
  • 1
    maybe check the answer here: stackoverflow.com/questions/62595459/… (Looks like you may want to set the file detector on the remote element?) Commented Jun 16, 2021 at 18:27
  • I am already setting the remote file detector as part of code snippet else it would fail always. ((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector()); Still its failing intermittently giving InvalidArgumentException Commented Jun 17, 2021 at 8:15
  • Any solution please Commented Jun 17, 2021 at 14:17
  • try setting it on the webelement... if this is random, though... I'd check things like file space in your container... (the file is transferred to your remote machine... then that path is put into the input) Commented Jun 17, 2021 at 16:59
  • 1
    I found the problem thanks. While we running our test in docker container , some other containers were getting started by different projects .so this problem was happening Commented Jun 18, 2021 at 11:50

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.