diff --git a/docs/src/api/class-locator.md b/docs/src/api/class-locator.md index 463b47849bd13..e3082abdd40b2 100644 --- a/docs/src/api/class-locator.md +++ b/docs/src/api/class-locator.md @@ -2178,6 +2178,9 @@ await page.getByLabel('Upload files').setInputFiles([ path.join(__dirname, 'file2.txt'), ]); +// Select a directory +await page.getByLabel('Upload directory').setInputFiles(path.join(__dirname, 'mydir')); + // Remove all the selected files await page.getByLabel('Upload file').setInputFiles([]); @@ -2196,6 +2199,9 @@ page.getByLabel("Upload file").setInputFiles(Paths.get("myfile.pdf")); // Select multiple files 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 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 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 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 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 page.get_by_label("Upload file").set_input_files([]) @@ -2247,6 +2259,9 @@ await page.GetByLabel("Upload file").SetInputFilesAsync("myfile.pdf"); // Select multiple files 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 await page.GetByLabel("Upload file").SetInputFilesAsync(new[] {}); diff --git a/docs/src/input.md b/docs/src/input.md index 1baf49e33d996..87f92099a73df 100644 --- a/docs/src/input.md +++ b/docs/src/input.md @@ -542,6 +542,9 @@ await page.getByLabel('Upload files').setInputFiles([ path.join(__dirname, 'file2.txt'), ]); +// Select a directory +await page.getByLabel('Upload directory').setInputFiles(path.join(__dirname, 'mydir')); + // Remove all the selected files await page.getByLabel('Upload file').setInputFiles([]); @@ -560,6 +563,9 @@ page.getByLabel("Upload file").setInputFiles(Paths.get("myfile.pdf")); // Select multiple files 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 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 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 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 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 page.get_by_label("Upload file").set_input_files([]) @@ -611,6 +623,9 @@ await page.GetByLabel("Upload file").SetInputFilesAsync("myfile.pdf"); // Select multiple files 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 await page.GetByLabel("Upload file").SetInputFilesAsync(new[] {}); diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts index 43a89fbad2c65..28250cb271b0b 100644 --- a/packages/playwright-core/types/types.d.ts +++ b/packages/playwright-core/types/types.d.ts @@ -12804,6 +12804,9 @@ export interface Locator { * path.join(__dirname, 'file2.txt'), * ]); * + * // Select a directory + * await page.getByLabel('Upload directory').setInputFiles(path.join(__dirname, 'mydir')); + * * // Remove all the selected files * await page.getByLabel('Upload file').setInputFiles([]); *