mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs: examples for file directory upload (#31302)
This commit is contained in:
parent
d0b052e1e0
commit
a76e5824c0
@ -2178,6 +2178,9 @@ await page.getByLabel('Upload files').setInputFiles([
|
|||||||
path.join(__dirname, 'file2.txt'),
|
path.join(__dirname, 'file2.txt'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Select a directory
|
||||||
|
await page.getByLabel('Upload directory').setInputFiles(path.join(__dirname, 'mydir'));
|
||||||
|
|
||||||
// Remove all the selected files
|
// Remove all the selected files
|
||||||
await page.getByLabel('Upload file').setInputFiles([]);
|
await page.getByLabel('Upload file').setInputFiles([]);
|
||||||
|
|
||||||
@ -2196,6 +2199,9 @@ page.getByLabel("Upload file").setInputFiles(Paths.get("myfile.pdf"));
|
|||||||
// Select multiple files
|
// Select multiple files
|
||||||
page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
|
page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
|
||||||
|
|
||||||
|
// Select a directory
|
||||||
|
page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
|
||||||
|
|
||||||
// Remove all the selected files
|
// Remove all the selected files
|
||||||
page.getByLabel("Upload file").setInputFiles(new Path[0]);
|
page.getByLabel("Upload file").setInputFiles(new Path[0]);
|
||||||
|
|
||||||
@ -2211,6 +2217,9 @@ await page.get_by_label("Upload file").set_input_files('myfile.pdf')
|
|||||||
# Select multiple files
|
# Select multiple files
|
||||||
await page.get_by_label("Upload files").set_input_files(['file1.txt', 'file2.txt'])
|
await page.get_by_label("Upload files").set_input_files(['file1.txt', 'file2.txt'])
|
||||||
|
|
||||||
|
# Select a directory
|
||||||
|
await page.get_by_label("Upload directory").set_input_files('mydir')
|
||||||
|
|
||||||
# Remove all the selected files
|
# Remove all the selected files
|
||||||
await page.get_by_label("Upload file").set_input_files([])
|
await page.get_by_label("Upload file").set_input_files([])
|
||||||
|
|
||||||
@ -2229,6 +2238,9 @@ page.get_by_label("Upload file").set_input_files('myfile.pdf')
|
|||||||
# Select multiple files
|
# Select multiple files
|
||||||
page.get_by_label("Upload files").set_input_files(['file1.txt', 'file2.txt'])
|
page.get_by_label("Upload files").set_input_files(['file1.txt', 'file2.txt'])
|
||||||
|
|
||||||
|
# Select a directory
|
||||||
|
page.get_by_label("Upload directory").set_input_files('mydir')
|
||||||
|
|
||||||
# Remove all the selected files
|
# Remove all the selected files
|
||||||
page.get_by_label("Upload file").set_input_files([])
|
page.get_by_label("Upload file").set_input_files([])
|
||||||
|
|
||||||
@ -2247,6 +2259,9 @@ await page.GetByLabel("Upload file").SetInputFilesAsync("myfile.pdf");
|
|||||||
// Select multiple files
|
// Select multiple files
|
||||||
await page.GetByLabel("Upload files").SetInputFilesAsync(new[] { "file1.txt", "file12.txt" });
|
await page.GetByLabel("Upload files").SetInputFilesAsync(new[] { "file1.txt", "file12.txt" });
|
||||||
|
|
||||||
|
// Select a directory
|
||||||
|
await page.GetByLabel("Upload directory").SetInputFilesAsync("mydir");
|
||||||
|
|
||||||
// Remove all the selected files
|
// Remove all the selected files
|
||||||
await page.GetByLabel("Upload file").SetInputFilesAsync(new[] {});
|
await page.GetByLabel("Upload file").SetInputFilesAsync(new[] {});
|
||||||
|
|
||||||
|
|||||||
@ -542,6 +542,9 @@ await page.getByLabel('Upload files').setInputFiles([
|
|||||||
path.join(__dirname, 'file2.txt'),
|
path.join(__dirname, 'file2.txt'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Select a directory
|
||||||
|
await page.getByLabel('Upload directory').setInputFiles(path.join(__dirname, 'mydir'));
|
||||||
|
|
||||||
// Remove all the selected files
|
// Remove all the selected files
|
||||||
await page.getByLabel('Upload file').setInputFiles([]);
|
await page.getByLabel('Upload file').setInputFiles([]);
|
||||||
|
|
||||||
@ -560,6 +563,9 @@ page.getByLabel("Upload file").setInputFiles(Paths.get("myfile.pdf"));
|
|||||||
// Select multiple files
|
// Select multiple files
|
||||||
page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
|
page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
|
||||||
|
|
||||||
|
// Select a directory
|
||||||
|
page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
|
||||||
|
|
||||||
// Remove all the selected files
|
// Remove all the selected files
|
||||||
page.getByLabel("Upload file").setInputFiles(new Path[0]);
|
page.getByLabel("Upload file").setInputFiles(new Path[0]);
|
||||||
|
|
||||||
@ -575,6 +581,9 @@ await page.get_by_label("Upload file").set_input_files('myfile.pdf')
|
|||||||
# Select multiple files
|
# Select multiple files
|
||||||
await page.get_by_label("Upload files").set_input_files(['file1.txt', 'file2.txt'])
|
await page.get_by_label("Upload files").set_input_files(['file1.txt', 'file2.txt'])
|
||||||
|
|
||||||
|
# Select a directory
|
||||||
|
await page.get_by_label("Upload directory").set_input_files('mydir')
|
||||||
|
|
||||||
# Remove all the selected files
|
# Remove all the selected files
|
||||||
await page.get_by_label("Upload file").set_input_files([])
|
await page.get_by_label("Upload file").set_input_files([])
|
||||||
|
|
||||||
@ -593,6 +602,9 @@ page.get_by_label("Upload file").set_input_files('myfile.pdf')
|
|||||||
# Select multiple files
|
# Select multiple files
|
||||||
page.get_by_label("Upload files").set_input_files(['file1.txt', 'file2.txt'])
|
page.get_by_label("Upload files").set_input_files(['file1.txt', 'file2.txt'])
|
||||||
|
|
||||||
|
# Select a directory
|
||||||
|
page.get_by_label("Upload directory").set_input_files('mydir')
|
||||||
|
|
||||||
# Remove all the selected files
|
# Remove all the selected files
|
||||||
page.get_by_label("Upload file").set_input_files([])
|
page.get_by_label("Upload file").set_input_files([])
|
||||||
|
|
||||||
@ -611,6 +623,9 @@ await page.GetByLabel("Upload file").SetInputFilesAsync("myfile.pdf");
|
|||||||
// Select multiple files
|
// Select multiple files
|
||||||
await page.GetByLabel("Upload files").SetInputFilesAsync(new[] { "file1.txt", "file12.txt" });
|
await page.GetByLabel("Upload files").SetInputFilesAsync(new[] { "file1.txt", "file12.txt" });
|
||||||
|
|
||||||
|
// Select a directory
|
||||||
|
await page.GetByLabel("Upload directory").SetInputFilesAsync("mydir");
|
||||||
|
|
||||||
// Remove all the selected files
|
// Remove all the selected files
|
||||||
await page.GetByLabel("Upload file").SetInputFilesAsync(new[] {});
|
await page.GetByLabel("Upload file").SetInputFilesAsync(new[] {});
|
||||||
|
|
||||||
|
|||||||
3
packages/playwright-core/types/types.d.ts
vendored
3
packages/playwright-core/types/types.d.ts
vendored
@ -12804,6 +12804,9 @@ export interface Locator {
|
|||||||
* path.join(__dirname, 'file2.txt'),
|
* path.join(__dirname, 'file2.txt'),
|
||||||
* ]);
|
* ]);
|
||||||
*
|
*
|
||||||
|
* // Select a directory
|
||||||
|
* await page.getByLabel('Upload directory').setInputFiles(path.join(__dirname, 'mydir'));
|
||||||
|
*
|
||||||
* // Remove all the selected files
|
* // Remove all the selected files
|
||||||
* await page.getByLabel('Upload file').setInputFiles([]);
|
* await page.getByLabel('Upload file').setInputFiles([]);
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user