We have application where we do lot of file upload operations, the below code works in local if we keep the file in classpath say "src\test\resources\csvImports\sample.csv". Since its in local it gets the absolute path, however when we try to run from remote machine or Jenkins it fails saying path not found.
File f = new File("src/test/resources/csvImports/"+fileName); getDriver().findElement(By.xpath("//input[@type='file']")).sendKeys(f.getAbsolutePath());