Пример #1
0
 /**
  * Configures default Drupal driver to use before each scenario or outline.
  *
  * `@api` tagged scenarios will get the `api_driver` as the default driver.
  *
  * Other scenarios get the `default_driver` as the default driver.
  *
  * @param ScenarioEvent|OutlineEvent $event
  */
 public function prepareDefaultDrupalDriver($event)
 {
     $feature = $event->getFeature();
     $scenario = $event instanceof ScenarioLikeTested ? $event->getScenario() : $event->getOutline();
     // Get the default driver.
     $driver = $this->parameters['default_driver'];
     foreach (array_merge($feature->getTags(), $scenario->getTags()) as $tag) {
         if (!empty($this->parameters[$tag . '_driver'])) {
             $driver = $this->parameters[$tag . '_driver'];
         }
     }
     // Set the default driver.
     $this->drupal->setDefaultDriverName($driver);
     // Set the environment.
     $environment = $event->getEnvironment();
     $this->drupal->setEnvironment($environment);
 }
 /**
  * Close modal dialog if test scenario fails on CMS page
  *
  * @AfterScenario
  */
 public function closeModalDialog(ScenarioEvent $event)
 {
     // Only for failed tests on CMS page
     if (4 === $event->getResult()) {
         $cmsElement = $this->getSession()->getPage()->find('css', '.cms');
         if ($cmsElement) {
             try {
                 // Navigate away triggered by reloading the page
                 $this->getSession()->reload();
                 $this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
             } catch (\WebDriver\Exception $e) {
                 // no-op, alert might not be present
             }
         }
     }
 }