Merge pull request #143 from open-sausages/pulls/4.0/alert-text-check

API Add check for text in current alert
This commit is contained in:
Ingo Schommer 2017-01-12 16:19:13 +13:00 committed by GitHub
commit 6907f986f7
1 changed files with 18 additions and 2 deletions

View File

@ -8,6 +8,8 @@ use Behat\Behat\Event\StepEvent;
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;
@ -60,11 +62,13 @@ class BasicContext extends BehatContext
* 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);
}
/**
@ -479,6 +483,18 @@ JS;
$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$/
*/