diff --git a/tests/behat/app_behat_runtime.js b/tests/behat/app_behat_runtime.js index 7d04487c1..baab56f95 100644 --- a/tests/behat/app_behat_runtime.js +++ b/tests/behat/app_behat_runtime.js @@ -515,12 +515,20 @@ * * @param {HTMLElement} element Element to press. */ - const pressElement = function(element) { + const pressElement = async function(element) { // Scroll the item into view. + const initialRect = element.getBoundingClientRect(); + element.scrollIntoView(false); + await new Promise(resolve => requestAnimationFrame(resolve)); + const rect = element.getBoundingClientRect(); + if (initialRect.y !== rect.y) { + await new Promise(resolve => setTimeout(resolve, 300)); + } + // Simulate a mouse click on the button. const eventOptions = { clientX: rect.left + rect.width / 2,