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

Browser log support #81

Merged
merged 1 commit into from
Sep 26, 2023
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
14 changes: 9 additions & 5 deletions src/lib/Core/Log/TestLogProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

namespace Ibexa\Behat\Core\Log;

use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Session;
use Facebook\WebDriver\Remote\DriverCommand;
use Ibexa\Behat\Browser\Filter\BrowserLogFilter;
use WebDriver\LogType;
use OAndreyev\Mink\Driver\WebDriver;

final class TestLogProvider
{
Expand Down Expand Up @@ -41,21 +41,25 @@ public function getBrowserLogs(): array
{
$driver = $this->session->getDriver();

if (!($driver instanceof Selenium2Driver) || !$this->session->isStarted()) {
if (!($driver instanceof WebDriver) || !$this->session->isStarted()) {
return [];
}

if ($this->hasCachedLogs()) {
return $this->getCachedLogs();
}

$logs = $driver->getWebDriverSession()->log(LogType::BROWSER) ?? [];
$parsedLogs = $this->parseBrowserLogs($logs);
$parsedLogs = $this->parseBrowserLogs($this->getSeleniumLog($driver));
$this->cacheLogs($parsedLogs);

return $parsedLogs;
}

private function getSeleniumLog(WebDriver $driver): array
{
return $driver->getWebDriver()->execute(DriverCommand::GET_LOG, ['type' => 'browser']) ?? [];
}

public function getApplicationLogs(): array
{
$logReader = new LogFileReader();
Expand Down
Loading