Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Let selenium2driver do things with alerts #258

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions src/Context/BasicContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Behat\Behat\Hook\Scope\AfterStepScope;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Behat\Hook\Scope\BeforeStepScope;
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Element\NodeElement;
use Behat\Mink\Exception\ElementNotFoundException;
use Behat\Mink\Session;
Expand Down Expand Up @@ -562,7 +563,12 @@ public function theElementAttributeShouldBe($selector, $attribute, $value)
*/
public function iSeeTheDialogText($expected)
{
$text = $this->getExpectedAlert()->getText();
$driver = $this->getSession()->getDriver();
if ($driver instanceof Selenium2Driver) {
$text = $driver->getWebDriverSession()->getAlert_text();
} else {
$text = $this->getExpectedAlert()->getText();
}
Assert::assertStringContainsString($expected, $text);
}

Expand Down Expand Up @@ -597,12 +603,17 @@ protected function getExpectedAlert()
*/
public function iConfirmTheDialog()
{
$session = $this->getWebDriverSession();
$session->wait()->until(
WebDriverExpectedCondition::alertIsPresent(),
"Alert is expected"
);
$session->switchTo()->alert()->accept();
$driver = $this->getSession()->getDriver();
if ($driver instanceof Selenium2Driver) {
$driver->getWebDriverSession()->accept_alert();
} else {
$session = $this->getWebDriverSession();
$session->wait()->until(
WebDriverExpectedCondition::alertIsPresent(),
"Alert is expected"
);
$session->switchTo()->alert()->accept();
}
$this->handleAjaxTimeout();
}

Expand All @@ -611,7 +622,12 @@ public function iConfirmTheDialog()
*/
public function iDismissTheDialog()
{
$this->getExpectedAlert()->dismiss();
$driver = $this->getSession()->getDriver();
if ($driver instanceof Selenium2Driver) {
$driver->getWebDriverSession()->dismiss_alert();
} else {
$this->getExpectedAlert()->dismiss();
}
$this->handleAjaxTimeout();
}

Expand Down
Loading