tests: Avoid using autofocus for click_element tests

Similarly to the last commit (982b8bdcec),
we run into a race between autofocus triggering and the test trying to
click the focused element.

This also affects the "when there is none" test, which loses the focus
before it has been set, thus ending up with a focused element but expecting
none.

We fix both in one go by manually focusing things with a tab keypress
instead of using autofocus.

See #8145 and #5390.
This commit is contained in:
Florian Bruhin 2024-03-27 13:03:39 +01:00
parent 982b8bdcec
commit 481542844d
2 changed files with 3 additions and 4 deletions

View File

@ -7,7 +7,7 @@
<span onclick='console.log("click_element special chars")'>"Don't", he shouted</span>
<span>Duplicate</span>
<span class='clickable' onclick='console.log("click_element CSS selector")'>Duplicate</span>
<form><input autofocus id='qute-input'></input></form>
<form><input id='qute-input' onfocus='console.log("qute-input focused")'></input></form>
<a href="/data/hello.txt" id='link'>link</a>
<span id='foo.bar' onclick='console.log("id with dot")'>ID with dot</span>
<span style='position: absolute; left: 20px;top: 42px; width:10px; height:10px;'

View File

@ -502,14 +502,13 @@ Feature: Various utility commands.
Scenario: Clicking on focused element when there is none
When I open data/click_element.html
# Need to loose focus on input element
And I run :click-element position 20,42
And I wait for the javascript message "click_element position"
And I run :click-element focused
Then the error "No element found with focus!" should be shown
Scenario: Clicking on focused element
When I open data/click_element.html
And I run :fake-key <Tab>
And I wait for the javascript message "qute-input focused"
And I run :click-element focused
Then "Entering mode KeyMode.insert (reason: clicking input)" should be logged