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 constants
    // Navigate to upload image view
    open("https://images.google.com/")
        .setElement(byCssSelector("div[aria-label='Search by image']"))
        .waitFor(10).untilIsVisible().click()
        .setElement(byCssSelector("a[href='about:invalid#zClosurez']"))
        .waitFor(10).untilIsVisible().click();
    E(byCssSelector("input[name='encoded_image']")).waitFor(10);

    E(byCssSelector("body")).saveScreenshot("before_upload.png");

    // Upload Loadero sample image
    setFile(
        byCssSelector("input[name='encoded_image']"),
        loaderoConstants.getSampleFiles().getPNG100KB()
    );

    sleep(10*1000);

    E(byCssSelector("div#res")).waitFor(10).untilIsVisible();

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