From b22e3e61703c492ffee743cb459dd8bd9bd092c2 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 10 Aug 2015 16:45:38 -0700 Subject: [PATCH] MDL-50516 core_behat: added ability to go back, forward and reload the browser --- lib/tests/behat/behat_general.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/tests/behat/behat_general.php b/lib/tests/behat/behat_general.php index b12eb48982b..ba36cff5161 100644 --- a/lib/tests/behat/behat_general.php +++ b/lib/tests/behat/behat_general.php @@ -1405,4 +1405,25 @@ class behat_general extends behat_base { fwrite(STDOUT, "\033[2A\033[u\033[2B"); } } + + /** + * Presses a given button in the browser. + * + * @Then /^I press the "(back|forward|reload)" button in the browser$/ + * @param string $button the button to press. + * @throws ExpectationException + */ + public function i_press_in_the_browser($button) { + $session = $this->getSession(); + + if ($button == 'back') { + $session->back(); + } else if ($button == 'forward') { + $session->forward(); + } else if ($button == 'reload') { + $session->reload(); + } else { + throw new ExpectationException('Unknown browser button.', $session); + } + } } -- 2.11.4.GIT