Webdriver: Allow error when selecting file at ElementSendKeys (#38158)

Based on [spec](https://w3c.github.io/webdriver/#element-send-keys),

> 5. Verify that each file given by the user exists. If any do not,
return [error](https://w3c.github.io/webdriver/#dfn-error) with [error
code](https://w3c.github.io/webdriver/#dfn-error-code) [invalid
argument](https://w3c.github.io/webdriver/#dfn-invalid-argument).

---------

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
This commit is contained in:
Kenzie Raditya Tirtarahardja 2025-07-18 14:40:40 +08:00 committed by GitHub
parent a91625a332
commit 39144bb013
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 25 deletions

View file

@ -1114,11 +1114,12 @@ pub(crate) fn handle_will_send_keys(
}
// Step 8.5
// TODO: Should return invalid argument error if file doesn't exist
// InvalidArgument Error is returned if the files are not valid.
// Step 8.6 - 8.7
// Input and change event already fired in `htmlinputelement.rs`.
file_input.SelectFiles(files, can_gc);
if file_input.select_files(Some(files), can_gc).is_err() {
return Err(ErrorStatus::InvalidArgument);
}
// Step 8.8
return Ok(false);