prevent Chrome losing focus during systests - #12293
Conversation
|
The build artifacts for the build linked in the description will expire, and become unavailable in 6 months (soon this will change to 3 months I believe). So I'll attach the relevant files here: |
Co-authored-by: Reef Turner <feerrenrut@users.noreply.github.com>
| if self._popup_stole_focus(): | ||
| return self.wait_for_specific_speech(speech, afterIndex, maxWaitSeconds) |
There was a problem hiding this comment.
I actually don't think I saw any tests where this window being created mid system test was likely. Certainly there were situations where the popup had focus, but I doubt it was due to the popup being created mid test. Instead I suspect it was a result of NVDA "restoring focus" over the top of chrome due to a race condition during startup. I expect that the popup is first created much earlier, during the build.
Perhaps a comment in here (or the function) to say that this is to collect data on whether this is happening. And may be removed if we determine that it is not. An alternative approach may be to have an "allow list" of windows / processes that are allowed to gain focus after the test is started, anything else is a failure with the process name reported.
There was a problem hiding this comment.
This test where we sleep for 10s failed due to a docker popup: https://ci.appveyor.com/project/NVAccess/nvda/builds/38672328/artifacts.
@michaelDCurran also noted that we probably shouldn't be killing processes that developers may be running when running system tests locally. I'm going to remove this code in favour of the quick sleep fix and we can follow up to address the Docker issue later.
See test results for failed build of commit 959892a3d4 |
well it seems like this fix does not work - should we return to sleeping before launching chrome? |
See test results for failed build of commit 56f6f10d89 |
That build failure had the following log, from the screen shot I could confirm that the taskbar had focus. |
|
It's a shame to lose the logging for the startup task. |
|
My mistake, I looked at the "changes since last review" |
As discussed in #12293, our systems fail randomly. Usually this is due to another window stealing focus, such as the taskbar or Docker. As system tests are run locally, we shouldn't be killing these processes. Description of how this pull request fixes the issue: Use windows API to make the chrome window gain focus Adds logging that lists the foreground window and open windows if chrome doesn't gain focus Removes extra sleep time after starting NVDA
Link to issue number:
None
Summary of the issue:
Our system tests randomly fail due to chrome not having focus, and so NVDA does not read the expected speech. Sometimes this is due to a Docker popup asking for feedback such as this one .
Description of how this pull request fixes the issue:
postNvdaStartupfiresTesting strategy:
Run many builds to ensure system tests don't fail.
Known issues with pull request:
Change log entry:
None
Code Review Checklist: