Skip to content

Commit c591a14

Browse files
authored
test: do not create stray files when running tests (#1718)
1 parent eb08046 commit c591a14

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

playwright/src/test/java/com/microsoft/playwright/TestPageSetInputFiles.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,10 @@ void shouldUploadAFolder(@TempDir Path tmpDir) throws IOException {
471471
}
472472

473473
@Test
474-
void shouldUploadAFolderAndThrowForMultipleDirectories() throws IOException {
474+
void shouldUploadAFolderAndThrowForMultipleDirectories(@TempDir Path tmpDir) throws IOException {
475475
page.navigate(server.PREFIX + "/input/folderupload.html");
476476
Locator input = page.locator("input[name=\"file1\"]");
477-
Path dir = Paths.get("file-upload-test"); // Adjust path as necessary
477+
Path dir = tmpDir.resolve("file-upload-test");
478478
Files.createDirectories(dir.resolve("folder1"));
479479
writeFile(dir.resolve("folder1").resolve("file1.txt"), "file1 content");
480480
Files.createDirectories(dir.resolve("folder2"));
@@ -485,11 +485,11 @@ void shouldUploadAFolderAndThrowForMultipleDirectories() throws IOException {
485485
}
486486

487487
@Test
488-
void shouldThrowIfADirectoryAndFilesArePassed() throws IOException {
488+
void shouldThrowIfADirectoryAndFilesArePassed(@TempDir Path tmpDir) throws IOException {
489489
// Skipping conditions based on environment not directly translatable to Java; needs custom implementation
490490
page.navigate(server.PREFIX + "/input/folderupload.html");
491491
Locator input = page.locator("input[name=\"file1\"]");
492-
Path dir = Paths.get("file-upload-test"); // Adjust path as necessary
492+
Path dir = tmpDir.resolve("file-upload-test");
493493
Files.createDirectories(dir.resolve("folder1"));
494494
writeFile(dir.resolve("folder1").resolve("file1.txt"), "file1 content");
495495
PlaywrightException e = assertThrows(PlaywrightException.class,
@@ -498,10 +498,10 @@ void shouldThrowIfADirectoryAndFilesArePassed() throws IOException {
498498
}
499499

500500
@Test
501-
void shouldThrowWhenUploadingAFolderInANormalFileUploadInput() throws IOException {
501+
void shouldThrowWhenUploadingAFolderInANormalFileUploadInput(@TempDir Path tmpDir) throws IOException {
502502
page.navigate(server.PREFIX + "/input/fileupload.html");
503503
Locator input = page.locator("input[name=\"file1\"]");
504-
Path dir = Paths.get("file-upload-test"); // Adjust path as necessary
504+
Path dir = tmpDir.resolve("file-upload-test");
505505
Files.createDirectories(dir);
506506
writeFile(dir.resolve("file1.txt"), "file1 content");
507507
PlaywrightException e = assertThrows(PlaywrightException.class,

0 commit comments

Comments
 (0)