Skip to content

Lupa API Reference / commands / FileChooser

Class: FileChooser

Defined in: src/commands/file_chooser.ts:34

Represents a file chooser dialog that was opened in the browser.

Use-when

Use when a user action (like clicking a custom-styled upload button) triggers a native file chooser dialog.

Dont-use-when

Do not use if the <input type="file"> element is accessible directly. In those cases, use locator.setInputFiles() instead.

Constructors

Constructor

new FileChooser(id, isMultiple): FileChooser

Defined in: src/commands/file_chooser.ts:41

Creates an instance of FileChooser.

Parameters

id

string

The unique identifier of the file chooser tracked on the runner.

isMultiple

boolean

Whether the file chooser accepts multiple files.

Returns

FileChooser

Properties

id

readonly id: string

Defined in: src/commands/file_chooser.ts:42

The unique identifier of the file chooser tracked on the runner.


isMultiple

readonly isMultiple: boolean

Defined in: src/commands/file_chooser.ts:43

Whether the file chooser accepts multiple files.

Methods

setFiles()

setFiles(files, options?): Promise<void>

Defined in: src/commands/file_chooser.ts:58

Sets the files to upload on this file chooser.

Parameters

files

string | string[]

A file path or array of file paths.

options?

FileChooserSetFilesOptions

Optional settings.

Returns

Promise<void>

A promise that resolves when the files are set.

Example

typescript
await fc.setFiles('package.json')