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

Coverage: Don't attempt to read cookies while an alert is open #6211

Merged
merged 2 commits into from May 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Codeception/Coverage/Subscriber/LocalServer.php
Expand Up @@ -9,6 +9,7 @@
use Codeception\Events;
use Codeception\Exception\ModuleException;
use Codeception\Exception\RemoteException;
use Facebook\WebDriver\Exception\NoSuchAlertException;

/**
* When collecting code coverage data from local server HTTP requests are sent to c3.php file.
Expand Down Expand Up @@ -237,6 +238,19 @@ protected function startCoverageCollection($testName)

protected function fetchErrors()
{
// Calling grabCookie() while an alert is present dismisses the alert
// @see https://github.com/Codeception/Codeception/issues/1485
if ($this->module instanceof \Codeception\Module\WebDriver) {
try {
$alert = $this->module->webDriver->switchTo()->alert();
$alert->getText();
// If this succeeds an alert is present, abort
return;
} catch (NoSuchAlertException $e) {
// No alert present, continue
}
}

try {
$error = $this->module->grabCookie(self::COVERAGE_COOKIE_ERROR);
} catch (ModuleException $e) {
Expand Down