Skip to content

Instantly share code, notes, and snippets.

@MaksymKrut
Created October 2, 2016 15:56
Show Gist options
  • Save MaksymKrut/811dc4ad941ab76d879d00db7523e29a to your computer and use it in GitHub Desktop.
Save MaksymKrut/811dc4ad941ab76d879d00db7523e29a to your computer and use it in GitHub Desktop.
File upload with Selenium.
public static void uploadFile(WebElement uploadField, String name) throws InterruptedException, IOException {
File file = new File("src/main/resources/test.pdf");
String absolutePath = file.getAbsolutePath();
System.out.println("\n\nFile absolute path: " + absolutePath + "\n\n");
uploadField.sendKeys(absolutePath);
Thread.sleep(100 * 1000);
System.out.println("\n\nFile with name: " + name + " has uploaded!\n\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment