Bring the browser window of an actor to the foreground when acting as him #12063
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.
This pull request works around a bug in the Firefox driver of Selenium and/or Firefox itself (I tracked the bug down to Selenium, but I am not sure if it comes from it or even deeper, and unfortunately I do not have time to keep digging ;-) ). However, it does not fix any existing issue with the acceptance tests, but makes them more robust preventing the bug from manifesting in future tests.
Due to the bug, if a window is in the background, it is not possible to set the value of an input field that has a range selected. To set a value in an input field the Selenium extension for Mink sends as many delete and backspace characters as characters are currently in the field (thus clearing it no matter where the cursor is), and then sends the new value. However, when the window is in the background and the input field has a range selected, only the selected range is modified (even if as many delete and backspace characters as characters are in total are sent), so the input field ends having the new value surrounded by the part of the old value that was not in the selected range.
How does this affect the acceptance tests? Each time a new actor appears in a scenario the browser window of the new actor is put in front of the browser windows of the previous actors. When acting again as a previous actor his browser window stayed in the background, and here is where the problem appeared. For example, it would not be possible to rename a file in the Files app with a previous actor (although it would work with the most recent one), as when a file is renamed the filename, but not the extension, is selected in the input field.
To work around the problem now when acting again as a previous actor his browser window is brought to the foreground (which also reflects better how a user would interact with the browser in real life).
I would like to backport this to stable14, as it only affects the acceptance tests, it could be needed if some future tests that rely on this (even unknowingly ;-)) are backported to stable14, and it could by needed by some tests in Talk 4.X, which is compatible only with Nextcloud 14.
How to test:
./run.sh features/login.feature:3
Without the workaround the test fails with