Set File

Set File #

client.setFile((selector: string), (fileName: string));

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.

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.

client => {
    // Example of setting sample file into file input field using constants
    client
        .url('https://images.google.com/')
        // Navigate to upload image view
        .waitForElementVisible('div[aria-label="Search by image"]', 10 * 1000)
        .click('div[aria-label="Search by image"]')
        .waitForElementVisible('a[href="about:invalid#zClosurez"]', 10 * 1000)
        .click('a[href="about:invalid#zClosurez"]')
        .waitForElementVisible('input[name="encoded_image"]', 10 * 1000)
        // Upload Loadero sample image
        .setFile('input[name="encoded_image"]', loaderoConstants.sampleFiles.png100KB)
        .takeScreenshot('file_set.png')
        .waitForElementVisible('div#res', 10 * 1000)
        .takeScreenshot('search_by_image_results.png')
}