MDL-65831 behat: New steps to switch offline mode for moodle app behats
This commit is contained in:
parent
079697de89
commit
21803fc7f2
@ -240,9 +240,12 @@
|
|||||||
var exactLabelMatches = [];
|
var exactLabelMatches = [];
|
||||||
var anyLabelMatches = [];
|
var anyLabelMatches = [];
|
||||||
findPossibleMatches('//*[@aria-label and contains(@aria-label, "' + escapedText + '")]' +
|
findPossibleMatches('//*[@aria-label and contains(@aria-label, "' + escapedText + '")]' +
|
||||||
|
'| //a[@title and contains(@title, "' + escapedText + '")]' +
|
||||||
'| //img[@alt and contains(@alt, "' + escapedText + '")]', function(match) {
|
'| //img[@alt and contains(@alt, "' + escapedText + '")]', function(match) {
|
||||||
// Add to array depending on if it's an exact or partial 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) {
|
if (attributeData.trim() === text) {
|
||||||
exactLabelMatches.push(match);
|
exactLabelMatches.push(match);
|
||||||
} else {
|
} else {
|
||||||
|
@ -524,4 +524,15 @@ class behat_app extends behat_base {
|
|||||||
$this->getSession()->getDriver()->executeScript('window.close()');
|
$this->getSession()->getDriver()->executeScript('window.close()');
|
||||||
$this->getSession()->switchToWindow($names[0]);
|
$this->getSession()->switchToWindow($names[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch navigator online mode.
|
||||||
|
*
|
||||||
|
* @Given /^I switch offline mode to "(?P<offline_string>(?:[^"]|\\")*)"$/
|
||||||
|
* @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 . ');');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user