Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion playwright/_impl/_set_input_files_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import base64
import collections.abc
import os
import stat
from pathlib import Path
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -144,7 +145,8 @@ def resolve_paths_and_directory_for_input_files(
local_paths: Optional[List[str]] = None
local_directory: Optional[str] = None
for item in items:
if os.path.isdir(item):
item_stat = os.stat(item) # Raises FileNotFoundError if doesn't exist
if stat.S_ISDIR(item_stat.st_mode):
if local_directory:
raise Error("Multiple directories are not supported")
local_directory = str(Path(item).resolve())
Expand Down
6 changes: 6 additions & 0 deletions tests/sync/test_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ def test_locators_should_upload_a_file(page: Page, server: Server) -> None:
)


def test_locators_upload_nonexistant_file(page: Page, server: Server) -> None:
page.goto(server.PREFIX + "/input/fileupload.html")
with pytest.raises(FileNotFoundError):
page.locator("input[type=file]").set_input_files("nonexistant.html")


def test_locators_should_press(page: Page) -> None:
page.set_content("<input type='text' />")
page.locator("input").press("h")
Expand Down
Loading