MDL-38958 behat: Step definitions to interact with popup windows
This commit is contained in:
@@ -63,6 +63,25 @@ class behat_general extends behat_base {
|
||||
$this->getSession()->reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches to the specified window. Useful when interacting with popup windows.
|
||||
*
|
||||
* @Given /^I switch to "(?P<window_name_string>(?:[^"]|\\")*)" window$/
|
||||
* @param string $windowname
|
||||
*/
|
||||
public function switch_to_window($windowname) {
|
||||
$this->getSession()->switchToWindow($windowname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches to the main Moodle window. Useful when you finish interacting with popup windows.
|
||||
*
|
||||
* @Given /^I switch to the main window$/
|
||||
*/
|
||||
public function switch_to_the_main_window() {
|
||||
$this->getSession()->switchToWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks link with specified id|title|alt|text.
|
||||
*
|
||||
|
||||
@@ -29,9 +29,10 @@
|
||||
|
||||
require_once(__DIR__ . '/../../behat/behat_base.php');
|
||||
|
||||
use Behat\Behat\Event\SuiteEvent as SuiteEvent;
|
||||
use Behat\Behat\Event\ScenarioEvent as ScenarioEvent;
|
||||
use Behat\Behat\Event\StepEvent as StepEvent;
|
||||
use Behat\Behat\Event\SuiteEvent as SuiteEvent,
|
||||
Behat\Behat\Event\ScenarioEvent as ScenarioEvent,
|
||||
Behat\Behat\Event\StepEvent as StepEvent,
|
||||
WebDriver\Exception\NoSuchWindow as NoSuchWindow;
|
||||
|
||||
/**
|
||||
* Hooks to the behat process.
|
||||
@@ -170,7 +171,11 @@ class behat_hooks extends behat_base {
|
||||
}
|
||||
|
||||
// Wait until the page is ready.
|
||||
$this->getSession()->wait(self::TIMEOUT, '(document.readyState === "complete")');
|
||||
try {
|
||||
$this->getSession()->wait(self::TIMEOUT, '(document.readyState === "complete")');
|
||||
} catch (NoSuchWindow $e) {
|
||||
// If we were interacting with a popup window it will not exists after closing it.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user