I am using Selenium WebDriver for automation. Uploading files in WebDriver is done by simply using the sendKeys() method on the file input field.
Code snippet:
WebElement uploadElement = driver.findElement(By.id("uploadfile"));
// enter the absolute file path into the file input field
uploadElement.sendKeys("C:\\test.txt");
Above code snippet works as expected when script execution is running on Local machine.. But it is not working when script execution is running on Zalenium docker container.
File upload is relatively very simple but slightly different when you are using Docker concept. You need to ensure that you set the file detector for the file (using LocalFileDetector class) which you want to upload.
Refer below code snippet:
Above code snippet will upload the file when script execution on Local/Remote/Zalenium docker container.