Set File

Set file #

def set_file(driver: TestUIDriver, element: Elements, file_name: str) -> None

The element parameter specifies the input element where file name has to be set.

The file_name parameter specifies chosen file name. To use files names more safely in code it’s recommended to use predefined constants.

Available test files #

File name (file_name)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.

def test(driver):
    # Example of setting sample file into file input field using string values
    driver.navigate_to("http://www.toledorocket.com/perftest/uploadtest/fileselect.asp")
    e(driver, "css", "body").wait_until_visible(seconds=10)

    set_file(driver, e(driver, "css", "input[type=FILE]"), "loaderoSample100KB.png")

    time.sleep(1)

    driver.save_screenshot("file_set.png")
def test(driver):
    # Example of setting sample file into file input field using constants
    driver.navigate_to("http://www.toledorocket.com/perftest/uploadtest/fileselect.asp")
    e(driver, "css", "body").wait_until_visible(seconds=10)

    set_file(
        driver,
        e(driver, "css", "input[type=FILE]"),
        LOADERO_CONSTANTS.sample_files.png_100KB,
    )

    time.sleep(1)

    driver.save_screenshot("file_set.png")