From fe6687f2ea6504a24be630ba00a765b526f12dbf Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 23 Mar 2023 18:06:52 +0100 Subject: tests: Stabilize "Hinting an input after undoing a tab close" Without this wait, the test is flaky, because sometimes the keys are pressed before qutebrowser has entered insert mode. When running: tox -e py311-pyqt64 -- tests/end2end/features/test_hints_bdd.py -k undoing --count 100 around 30% of the runs, we get: ============================== :click-element id qute-input-existing ============================== [...] ----> Waiting for 'command called: *' in the log [...] 17:56:54.042 DEBUG commands command:run:549 Calling qutebrowser.components.misccommands.click_element(, 'id', 'qute-input-existing', target=, force_event=False, select_first=False) 17:56:54.043 DEBUG ipc ipc:_get_socket:373 In _get_socket with None socket! ----> found it ============================== :fake-key -g something ============================== [...] ----> Waiting for '[*] contents: existingsomething' in the log 17:56:54.062 DEBUG modes modeman:_handle_keypress:290 got keypress in mode KeyMode.normal - delegating to [...] 17:56:54.111 DEBUG modes modeman:_handle_keypress:290 got keypress in mode KeyMode.normal - delegating to [...] 17:56:54.112 DEBUG modes modeman:_handle_keypress:290 got keypress in mode KeyMode.normal - delegating to [...] 17:56:54.113 DEBUG commands command:run:535 command called: quickmark-save [...] 17:56:54.143 DEBUG webview webenginetab:_js_cb_single:766 Got element from JS: {'attributes': {'id': 'qute-input-existing', 'value': 'existing'}, 'caret_position': 0, 'class_name': '', 'id': 0, 'is_content_editable': False, 'outer_xml': '', 'rects': [{'bottom': 143, 'height': 21, 'left': 8, 'right': 166, 'top': 122, 'width': 158}], 'tag_name': 'INPUT', 'text': '', 'value': 'existing'} 17:56:54.143 DEBUG webelem webelem:click:422 Clicking with click_target ClickTarget.normal, force_event False 17:56:54.143 DEBUG webelem webelem:is_editable:257 Checking if element is editable: 17:56:54.143 DEBUG webelem webelem:click:434 Clicking via JS focus() 17:56:54.144 DEBUG webelem webelem:is_editable:257 Checking if element is editable: 17:56:54.144 DEBUG modes modeman:enter:366 Entering mode KeyMode.insert (reason: clicking input) With the change, the test passes 100/100 times. --- tests/end2end/features/hints.feature | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/end2end/features/hints.feature b/tests/end2end/features/hints.feature index d6f48a87c..51ffb980a 100644 --- a/tests/end2end/features/hints.feature +++ b/tests/end2end/features/hints.feature @@ -628,5 +628,6 @@ Feature: Using hints And I run :undo And I wait until data/hints/link_input.html is loaded And I run :click-element id qute-input-existing + And I wait for "Entering mode KeyMode.insert (reason: clicking input)" in the log And I run :fake-key -g something Then the javascript message "contents: existingsomething" should be logged -- cgit v1.2.3-54-g00ecf