Skip to content

Commit

Permalink
Merge pull request #143 from open-sausages/pulls/4.0/alert-text-check
Browse files Browse the repository at this point in the history
API Add check for text in current alert
  • Loading branch information
chillu authored Jan 12, 2017
2 parents 4276dd9 + 9d083e0 commit 6907f98
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/SilverStripe/BehatExtension/Context/BasicContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Behat\Behat\Event\ScenarioEvent;
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Element\NodeElement;
use Behat\Mink\Session;
use Behat\MinkExtension\Context\RawMinkContext;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Filesystem;

Expand Down Expand Up @@ -60,11 +62,13 @@ public function __construct(array $parameters)
* Get Mink session from MinkContext
*
* @param string $name
* @return \Behat\Mink\Session
* @return Session
*/
public function getSession($name = null)
{
return $this->getMainContext()->getSession($name);
/** @var SilverStripeContext $context */
$context = $this->getMainContext();
return $context->getSession($name);
}

/**
Expand Down Expand Up @@ -479,6 +483,18 @@ public function iClickInTheElementDismissingTheDialog($clickType, $text, $select
$this->iDismissTheDialog();
}

/**
* @Given /^I see the text "([^"]+)" in the alert$/
*/
public function iSeeTheDialogText($expected)
{
$session = $this->getSession();
/** @var Selenium2Driver $driver */
$driver = $session->getDriver();
$text = $driver->getWebDriverSession()->getAlert_text();
assertContains($expected, $text);
}

/**
* @Given /^I type "([^"]*)" into the dialog$/
*/
Expand Down

0 comments on commit 6907f98

Please sign in to comment.