Skip to content

Commit

Permalink
Added browser logs for Selenium 4
Browse files Browse the repository at this point in the history
  • Loading branch information
mnocon committed Sep 26, 2023
1 parent 0ddb443 commit 0cf6700
Showing 1 changed file with 9 additions and 5 deletions.
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

0 comments on commit 0cf6700

Please sign in to comment.