Repository navigation
fix: fill_field no longer types into a field it did not capture (#56) - #61
Open
bluzername wants to merge 1 commit into
Open
bluzername wants to merge 1 commit into
bluzername wants to merge 1 commit into
Conversation
fill_field's keystroke fallback (clear_field + type_text) run on whatever field has focus at the moment it fires. Between the step's capture and this call there is the decision round trip and the settle delay, long enough for a page to move the focus. In that window the fallback can empty a field it never meant to touch. Now fill_field reads desktop.focused_field() right before clear_field and type_text, and it refuse, untouched, when that is not the same field the step captured (checked by role, label, placeholder and position, not by value, since typing is the very thing that would change the value). _type_text and _type_email both forward this refusal in the history line instead of going on as if the text landed somewhere. 5 new tests in tests/test_actions.py, RED->GREEN. Full suite 735 passed (730 + 5 new), ruff clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Fixes #56.
fill_field's keystroke fallback (clear_fieldthentype_text) act on whatever field has focus the moment it runs. Between the step's capture and this call there is the decision round trip and the settle delay - long enough for a page to move the focus somewhere else. In that window the fallback can empty a field it never meant to touch, same riskrestore_fieldalready refuses for the undo path ("Select All/Delete could destroy an unrelated field's contents"), but it was not guarded here.What changed:
Field.same_element()(models.py): tells whether a live field is the same one as a capturedField, by role, label, placeholder and position - not by value, since typing is exactly what would change the value.fill_field(actions.py): readsdesktop.focused_field()right beforeclear_field/type_textand refuse, untouched, when it is not the same field. Returns"refused: focus moved to a different field since the step was captured"._type_textand_type_emailboth forward this as"type_text refused: ..."/"type_email refused: ..."in the history line instead of acting like the text landed somewhere.Test evidence: 5 new tests in
tests/test_actions.py(focus moved to another field, nothing focused any more, same field still focused after a partial AX write, and propagation through_type_text/_type_email), RED confirmed against the old code then GREEN. Full suite: 735 passed (730 + 5 new), 2 skipped, 1 xfailed, unchanged otherwise.ruff checkandruff format --checkboth clean.I not a maintainer here, just opening this for review. Happy to adjust the identity check if you want a different definition of "same field".