Set File

Set file #

setFile(By selector, String fileName);

The selector parameter specifies input field element selector, e.g. input[type="file"], input#file-upload.

The fileName parameter specifies chosen file name. Choose desired file from the table below or use available constants.

Available test files #

File name (fileName)TypeSize
loaderoSample100KB.pngPNG100KB
loaderoSample1MB.pngPNG1MB
loaderoSample5MB.pngPNG5MB
loaderoSample30MB.pngPNG30MB
loaderoSample100MB.txtTXT100MB

In case there is a need for other file format or size, feel free to contact us.

public void testUIWithLoadero() {
  // Example of setting sample file into file input field using string values
  open("http://www.toledorocket.com/perftest/uploadtest/fileselect.asp")
    .setElement(byCssSelector("body"))
    .waitFor(10).untilIsVisible();

  setFile(byCssSelector("input[type=FILE]"), "loaderoSample100KB.png");
  sleep(1000);

  E(byCssSelector("body")).saveScreenshot("fileSet.png");
}
public void testUIWithLoadero() {
  // Example of setting sample file into file input field using constants
  open("http://www.toledorocket.com/perftest/uploadtest/fileselect.asp")
    .setElement(byCssSelector("body")).waitFor(10).untilIsVisible();

  setFile(byCssSelector(
    "input[type=FILE]"),
    loaderoConstants.getNetwork().getPNG100KB()
  );

  sleep(1000);

  E(byCssSelector("body")).saveScreenshot("fileSet.png");
}