In my case, works below method. I use Windows now, but after writing some tests, want transfer it to the *nix environment. And some cool guys says that path must be abstract one.
driver.findElement(By.id("admin_offer_kind_logo")).sendKeys("C:\\Path\\To\\File");
But of I try:
driver.findElement(By.id("admin_offer_kind_logo")).sendKeys(System.getProperty("user.dir")+"\\src\\test\\resources\\Koala.jpg");
or
driver.findElement(By.id("admin_offer_kind_logo")).sendKeys(System.getProperty("user.dir")+"/src/test/resources/Koala.jpg");
It doesn't wants to upload the goddamn file.
@Test
public void FileFinding() {
String file = System.getProperty("user.dir");
System.out.print("FilePath: ");
System.out.println(file);
}
Above code prints: FilePath: C:\SeleniumTests\FirstWebDriverTest
Full path to my file in project is:
C:\SeleniumTests\FirstWebDriverTest\src\test\resources\Koala.jpg