The proper way to upload a file on any OS is to
- Find the
<input type="file">
element. You need not to worry about different implementations and exact positioning. Just find the element for example by xpath//input[@type="file"]
sendKeys()
ortype()
(or whatever method writes text into elements in your language) the path to file to that input element.
Sample Java code:
// find the input element
WebElement elem = driver.findElement(By.xpath("//input[@type="file"]"));
// 'type' the file location to it as it were a usual <input type="text" /> element
elem.sendKeys("C://path/To/File.jpg");
This works on every OS and browser in WebDriver.