Assert selected file exists

This commit is contained in:
Axel Dahlberg 2021-03-21 12:33:14 +01:00
parent 28d828e35b
commit 12fac3c7a0
2 changed files with 14 additions and 1 deletions

View File

@ -434,5 +434,8 @@ def _execute_fileselect_command(
if not qb_mode == FileSelectionMode.multiple_files:
if len(selected_files) > 1:
message.warning("More than one file/folder chosen, using only the first")
return selected_files[:1]
selected_files = selected_files[:1]
for selected_file in selected_files:
if not os.path.exists(selected_file):
message.warning(f"Selected non-existent file '{selected_file}'")
return selected_files

View File

@ -240,6 +240,16 @@ Feature: Opening external editors
And the error "Failed to open tempfile *" should be shown
And "Failed to delete tempfile *" should be logged with level error
## Select non-existent file
Scenario: Select non-existent file
When I set fileselect.handler to external
When I setup a fake single_file fileselector selecting "tests/end2end/data/numbers/non-existent.txt" and writes to a temporary file
And I open data/fileselect.html
And I run :click-element id single_file
Then the javascript message "Files: non-existent.txt" should not be logged
And the warning "Selected non-existent file *tests/end2end/data/numbers/non-existent.txt'" should be shown
## Select folder
@qtwebkit_skip