mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 09:56:38 +02:00
MDL-68826 behat: new step I close all opened windows
This commit is contained in:
parent
2e324c14bf
commit
709cab79ed
1 changed files with 24 additions and 0 deletions
|
@ -243,6 +243,30 @@ class behat_general extends behat_base {
|
||||||
$this->getSession()->switchToWindow(self::MAIN_WINDOW_NAME);
|
$this->getSession()->switchToWindow(self::MAIN_WINDOW_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes all extra windows opened during the navigation.
|
||||||
|
*
|
||||||
|
* This assumes all popups are opened by the main tab and you will now get back.
|
||||||
|
*
|
||||||
|
* @Given /^I close all opened windows$/
|
||||||
|
* @throws DriverException If there aren't exactly 1 tabs open when finish or no javascript running
|
||||||
|
*/
|
||||||
|
public function i_close_all_opened_windows() {
|
||||||
|
if (!$this->running_javascript()) {
|
||||||
|
throw new DriverException('Closing windows steps require javascript');
|
||||||
|
}
|
||||||
|
$names = $this->getSession()->getWindowNames();
|
||||||
|
for ($index = 1; $index < count($names); $index ++) {
|
||||||
|
$this->getSession()->switchToWindow($names[$index]);
|
||||||
|
$this->getSession()->executeScript("window.open('', '_self').close();");
|
||||||
|
}
|
||||||
|
$names = $this->getSession()->getWindowNames();
|
||||||
|
if (count($names) !== 1) {
|
||||||
|
throw new DriverException('Expected to see 1 tabs open, not ' . count($names));
|
||||||
|
}
|
||||||
|
$this->getSession()->switchToWindow($names[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts the currently displayed alert dialog. This step does not work in all the browsers, consider it experimental.
|
* Accepts the currently displayed alert dialog. This step does not work in all the browsers, consider it experimental.
|
||||||
* @Given /^I accept the currently displayed dialog$/
|
* @Given /^I accept the currently displayed dialog$/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue