From 21803fc7f2b91b0653dbdbf6b8dbdd47bbb6dd59 Mon Sep 17 00:00:00 2001 From: Amaia Anabitarte Date: Fri, 31 May 2019 13:51:17 +0200 Subject: [PATCH] MDL-65831 behat: New steps to switch offline mode for moodle app behats --- app_behat_runtime.js | 5 ++++- behat_app.php | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app_behat_runtime.js b/app_behat_runtime.js index 08ccc8c79..3c9f3a496 100644 --- a/app_behat_runtime.js +++ b/app_behat_runtime.js @@ -240,9 +240,12 @@ var exactLabelMatches = []; var anyLabelMatches = []; findPossibleMatches('//*[@aria-label and contains(@aria-label, "' + escapedText + '")]' + + '| //a[@title and contains(@title, "' + escapedText + '")]' + '| //img[@alt and contains(@alt, "' + escapedText + '")]', function(match) { // Add to array depending on if it's an exact or partial match. - var attributeData = match.getAttribute('aria-label') || match.getAttribute('alt'); + var attributeData = match.getAttribute('aria-label') || + match.getAttribute('title') || + match.getAttribute('alt'); if (attributeData.trim() === text) { exactLabelMatches.push(match); } else { diff --git a/behat_app.php b/behat_app.php index fee3f56d9..aebbed109 100644 --- a/behat_app.php +++ b/behat_app.php @@ -524,4 +524,15 @@ class behat_app extends behat_base { $this->getSession()->getDriver()->executeScript('window.close()'); $this->getSession()->switchToWindow($names[0]); } + + /** + * Switch navigator online mode. + * + * @Given /^I switch offline mode to "(?P(?:[^"]|\\")*)"$/ + * @param string $offline New value for navigator online mode + * @throws DriverException If the navigator.online mode is not available + */ + public function i_switch_offline_mode(string $offline) { + $this->getSession()->evaluateScript('appProvider.setForceOffline(' . $offline . ');'); + } }