From 6b9c8667571cb7e960e06c0ae5c12a7d2bbb95a9 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Wed, 10 Apr 2013 16:50:52 +0800 Subject: [PATCH] MDL-38939 behat: Allow admin setting to be set in non-JS sessions --- admin/tests/behat/behat_admin.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/admin/tests/behat/behat_admin.php b/admin/tests/behat/behat_admin.php index cdca881ae4a..97a78a44477 100644 --- a/admin/tests/behat/behat_admin.php +++ b/admin/tests/behat/behat_admin.php @@ -58,7 +58,7 @@ class behat_admin extends behat_base { // We expect admin block to be visible, otherwise go to homepage. if (!$this->getSession()->getPage()->find('css', '.block_settings')) { $this->getSession()->visit($this->locate_path('/')); - $this->getSession()->wait(self::TIMEOUT, '(document.readyState === "complete")'); + $this->wait(self::TIMEOUT, '(document.readyState === "complete")'); } // Search by label. @@ -67,7 +67,7 @@ class behat_admin extends behat_base { $submitsearch = $this->find('css', 'form.adminsearchform input[type=submit]'); $submitsearch->press(); - $this->getSession()->wait(self::TIMEOUT, '(document.readyState === "complete")'); + $this->wait(self::TIMEOUT, '(document.readyState === "complete")'); // Admin settings does not use the same DOM structure than other moodle forms // but we also need to use lib/behat/form_field/* to deal with the different moodle form elements. @@ -94,4 +94,16 @@ class behat_admin extends behat_base { } } + /** + * Waits with the provided params if we are running a JS session. + * + * @param int $timeout + * @param string $javascript + * @return void + */ + protected function wait($timeout, $javascript = false) { + if ($this->running_javascript()) { + $this->getSession()->wait($timeout, $javascript); + } + } }