w3c / webdriver-bidi

Bidirectional WebDriver protocol for browser automation
https://w3c.github.io/webdriver-bidi/
363 stars 40 forks source link

Add a step to validate if the files which a client tries to set with `input.setFiles` command exist #677

Closed lutien closed 5 months ago

lutien commented 7 months ago

Similar to WebDriver Classic actions (see here point 8.5), for input.setFiles command we could add a step to validate if paths specified in files argument point to existing files.

OrKoN commented 7 months ago

The file can also be deleted before it is actually used but after it is set via automation but before it is used. I think allowing to test scenarios when the file does not exist at upload time is also interesting, so perhaps an optional validation?

whimboo commented 7 months ago

Isn't this a distinct scenario? When discussing input.setFiles, the primary focus is on file selection. In this context, each browser exclusively permits users to choose existing files through the file selection dialog. Selecting a non-existent file is not an option at this stage.

OrKoN commented 7 months ago

The HTML spec says that "Files can be from the filesystem or created on the fly, e.g., a picture taken from a camera connected to the user's device" and it does not look like there is a requirement that the file has to exist on the filesystem.

css-meeting-bot commented 6 months ago

The Browser Testing and Tools Working Group just discussed Add a step to validate if the files which a client tries to set with input.setFiles command exist.

The full IRC log of that discussion <AutomatedTester> topic: Add a step to validate if the files which a client tries to set with input.setFiles command exist
<AutomatedTester> github: https://github.com/w3c/webdriver-bidi/issues/677
<AutomatedTester> sasha: the question is should we error like webdriver classic if the file doesn't exist
<AutomatedTester> ... on the platform side we snapshot the file and then send it across and this can error
<jrandolf> q+
<AutomatedTester> ... does this make sense for everyone?
<AutomatedTester> ack next
<AutomatedTester> jrandolf: On chromium we don't do validation until the file is read
<AutomatedTester> ... it is probably fine to write a normative note as it is platform specific to say this could throw an error
<AutomatedTester> ... in chromium we take a more relaxed sense since we don't expect people to send fake files and I know this came from wpt that was sending fake files
<jgraham> q+
<AutomatedTester> q?
<AutomatedTester> ack next
<AutomatedTester> jgraham (IRC): I think there are definitely loads of situations where it could throw an error
<AutomatedTester> ... for most people they won't be sending fake files but we need to do it for testing the browser
<AutomatedTester> ... and appreciate it's a bit of a footgun but we can see if we can relax the requirement on our side
<AutomatedTester_> q?
<sasha> q+
<AutomatedTester> ack next
<AutomatedTester> sasha: we have fixed wpt tests to make temporary files and we won't have to create any spec changes?
<AutomatedTester> jgraham (IRC): I think we should have the spec updated to say it's an invalid argument like classic