Page MenuHomePhabricator

Find a way to prevent/mitigate/inform developers about selenium flakiness caused by interaction happening before event listeners are installed
Open, Needs TriagePublic

Description

In T389536#10664344 we have another example of selenium flakiness caused by the code interacting with an element before said element gets the event listeners that the interaction expects. For example, the test clicks a button expecting something to happen, but the thing does not happen because when the button is clicked it still does not have the event listener that triggers the thing.

In the past, I mitigated this issue with page-specific solutions such as waiting for a class to be added, or checking the number of attached event listeners directly. However, these do not work in general, and are not so robust (especially the second approach).

Ideally, we should have a way to either prevent these issues from happening (no idea if this is possible / what it might look like); or inform developers about them (in the docs?), and perhaps provide utility methods to deal with such situations.