@Override public File execute(SelenideElement proxy, WebElementSource locator, Object[] args) throws IOException { File[] file; if (args instanceof File[]) { file = (File[]) args; } else { file = (File[]) args[0]; } if (file.length == 0) { throw new IllegalArgumentException("No files to upload"); } WebElement inputField = locator.getWebElement(); File uploadedFile = uploadFile(locator.driver(), inputField, file[0]); if (file.length > 1) { SelenideElement form = proxy.closest("form"); List<WebElement> newInputs = cloneInputField(locator.driver(), form, inputField, file.length - 1); Config config = locator.driver().config(); Stopwatch stopwatch = new Stopwatch(config.timeout()); for (int i = 1; i < file.length; i++) { WebElement newInput = newInputs.get(i - 1); uploadSingleFile(config, file[i], stopwatch, newInput); } } return uploadedFile; }