[py] add BiDi upload tests that verify files actually reach the server - #18007
Merged
AutomatedTester merged 1 commit intoSep 9, 2026
Merged
Conversation
The existing `input.setFiles` tests stop at the file input's `value` property, which only shows the filename string was accepted. Classic `upload_tests.py` submits the form and reads what the endpoint echoed back, so it proves the bytes were transmitted; the BiDi tests did not. Add three tests to the `_bidi` input suite: - `test_set_files_posts_file_to_server` and its two-file variant mirror the classic upload tests, asserting the endpoint echoed back both the filename and the file content. - `test_type_and_set_files_in_same_form` covers filling a form the way a user does, typing into a text field and attaching a file in one flow. It also asserts `#fileResults` changed, so a real `change` event has to fire rather than just a value write. Co-Authored-By: Copse <noreply@copse.dev> Copse-Models: acp:claude-agent-acp#opus[1m]
This was referenced Sep 9, 2026
AutomatedTester
deleted the
copse/review-the-bidi-interaction-code-for-pytho-664836
branch
September 9, 2026 10:03
This was referenced Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Python BiDi suite already covers
input.setFiles, but every one of those tests stops at reading the file input'svalueproperty. That only shows the filename string was accepted — it does not show the file was actually attached or that its bytes were transmitted. Classicpy/test/selenium/webdriver/common/upload_tests.pygoes further: it submits the form and reads what the upload endpoint echoed back into the target iframe. The BiDi tests had no equivalent, so BiDi uploads were less well covered than classic ones.This adds three tests to
py/test/selenium/webdriver/common/_bidi/input_tests.py:test_set_files_posts_file_to_server— mirrors classictest_can_upload_file. Callsset_files, clicks#go, switches intoupload_target, and asserts the endpoint echoed back both the filename and the file's content. The content assertion is the load-bearing one: it can only appear if the bytes were really sent.test_set_files_posts_two_files_to_server— mirrors classictest_can_upload_two_files, asserting both files' distinct content markers.test_type_and_set_files_in_same_form— covers filling in a form the way a user actually does: type into a text field via BiDi key actions, then attach a file viaset_files, then assert both survived. It also asserts#fileResultsbecame"changed", so the file input'sonchangehandler has to fire — no existing BiDi test checks that a realchangeevent is dispatched rather than just a value being written.Motivation and Context
Came out of a review of the Python BiDi interaction code asking whether a user can type and upload under BiDi the same way they can under classic. Uploads were tested, but not to the same depth, and the type-plus-attach journey was not covered at all.
Worth noting for reviewers: the underlying
setFilestests in Java, Ruby, JS, and .NET also assert only ongetAttribute("value"), so the same coverage gap exists in the other bindings. This PR only fixes Python; happy to file a parity follow-up.I deliberately did not add a text field to
common/src/web/upload.html. That would have let the type-and-upload test round-trip through the server too, but the fixture is shared with every binding, and the JavaUploadHandlerreuses a singlevaluesmap across multipart parts (java/test/org/openqa/selenium/environment/webserver/UploadHandler.java:59), so an extra form part would concatenate into the content it returns and likely break Java's upload tests. UsingformPage.htmlcovers the same journey without that blast radius.Types of changes
Checklist
Verification
_bidi/input_tests.py(30 tests) green on Chrome and Firefox viabazel test //py:test/selenium/webdriver/common/_bidi/input_tests-{chrome,firefox}-bidi --cache_test_results=no.files=[file_path]tofiles=[]in the round-trip test and confirmed it fails withTimeoutException, then reverted.ruff formatandruff checkclean.AI assistance disclosure
Per
CONTRIBUTING.md, disclosing for reviewer context: the three tests were drafted with Claude Code, then reviewed, run, and verified by me (including the negative check above). NoCo-Authored-Bytag for the tool, per the same policy.Co-Authored-By: Copse noreply@copse.dev
Copse-Models: acp:claude-agent-acp#opus[1m]