diff --git a/local_moodleappbehat/tests/behat/behat_app.php b/local_moodleappbehat/tests/behat/behat_app.php index 498b1c111..aeacba67a 100644 --- a/local_moodleappbehat/tests/behat/behat_app.php +++ b/local_moodleappbehat/tests/behat/behat_app.php @@ -214,10 +214,7 @@ class behat_app extends behat_app_helper { return true; }); - $this->wait_for_pending_js(); - - // Wait scroll animation to finish. - $this->getSession()->wait(300); + $this->wait_animations_done(); } /** @@ -263,10 +260,7 @@ class behat_app extends behat_app_helper { throw new DriverException('Error when swiping - ' . $result); } - $this->wait_for_pending_js(); - - // Wait swipe animation to finish. - $this->getSession()->wait(300); + $this->wait_animations_done(); } /** @@ -689,10 +683,7 @@ class behat_app extends behat_app_helper { return true; }); - $this->wait_for_pending_js(); - - // Wait for UI to settle after refreshing. - $this->getSession()->wait(300); + $this->wait_animations_done(); if (is_null($locator)) { return; diff --git a/local_moodleappbehat/tests/behat/behat_app_helper.php b/local_moodleappbehat/tests/behat/behat_app_helper.php index c5538a701..d67fa4a82 100644 --- a/local_moodleappbehat/tests/behat/behat_app_helper.php +++ b/local_moodleappbehat/tests/behat/behat_app_helper.php @@ -641,4 +641,15 @@ EOF; return $text; } } + + /** + * Wait until animations have finished. + */ + protected function wait_animations_done() { + $this->wait_for_pending_js(); + + // Ideally, we wouldn't wait a fixed amount of time. But it is not straightforward to wait for animations + // to finish, so for now we'll just wait 300ms. + usleep(300000); + } }