Skip to content

Commit

Permalink
MOBILE-3947 behat: Reimplement wait
Browse files Browse the repository at this point in the history
The behaviour of wait for new versions has changed, so we need to implement it ourselves. See oleg-andreyev/MinkPhpWebDriver#81
  • Loading branch information
NoelDeMartin committed Dec 5, 2023
1 parent 50f3b92 commit f435363
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
15 changes: 3 additions & 12 deletions local_moodleappbehat/tests/behat/behat_app.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,7 @@ public function i_scroll_to_in_the_app(string $locator) {
return true;
});

$this->wait_for_pending_js();

// Wait scroll animation to finish.
$this->getSession()->wait(300);
$this->wait_animations_done();
}

/**
Expand Down Expand Up @@ -263,10 +260,7 @@ public function i_swipe_in_the_app(string $direction, bool $hasLocator = false,
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();
}

/**
Expand Down Expand Up @@ -689,10 +683,7 @@ public function i_pull_to_refresh_in_the_app(?string $locator = null) {
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;
Expand Down
11 changes: 11 additions & 0 deletions local_moodleappbehat/tests/behat/behat_app_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -641,4 +641,15 @@ protected function transform_time_to_string(string $text): string {
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);
}
}

0 comments on commit f435363

Please sign in to comment.