Repository navigation
fix(core): allow empty text in fill and keyboard_type in demo mode - #431
Open
VitorCoelho wants to merge 1 commit into
Open
VitorCoelho wants to merge 1 commit into
VitorCoelho wants to merge 1 commit into
Conversation
In demo mode, fill() and keyboard_type() compute the typing delay as
2000 / len(text), so an empty string raised ZeroDivisionError. The
action failed and, for fill(), the field was not cleared, while the
same action works when demo mode is off.
Guard the division so that empty text behaves the same in every demo
mode, and add a test for fill(bid, "") and keyboard_type("").
This branch has not been deployed
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.
What
fill()andkeyboard_type()raisedZeroDivisionErrorin demo mode when the text was empty, because the typing delay is computed as2000 / len(text). This change guards that division (max(len(text), 1)), so the delay for non-empty text is unchanged.Why
With demo mode off,
fill(bid, "")clears the field andkeyboard_type("")does nothing, as expected. With any other demo mode (default,all_blue,only_visible_elements) the same actions fail withZeroDivisionError: division by zeroinlast_action_error, andfill()leaves the old value in the field. Clearing a field withfill(bid, "")is a common agent action, so the result of an episode depended on whether demo mode was on.How it was tested
test_fill_type_empty_text, parametrized overdemo_modeoffanddefault:fill(bid, ""),fill(bid, "", True)andkeyboard_type(""). Thedefaultcase fails onmainwithZeroDivisionErrorand passes with this change.tests/core/data/input_type/text_input.html): all now clear the field without an error; non-empty values behave as before.pytest tests/core/test_actions_highlevel.py: 20 passed.black --check(24.2.0) is clean.