From 0cf6700fa88cdd108f534b50424cc70babd3936f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Tue, 26 Sep 2023 11:35:34 +0200 Subject: [PATCH] Added browser logs for Selenium 4 --- src/lib/Core/Log/TestLogProvider.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/Core/Log/TestLogProvider.php b/src/lib/Core/Log/TestLogProvider.php index 4f845849..10ebd8f0 100644 --- a/src/lib/Core/Log/TestLogProvider.php +++ b/src/lib/Core/Log/TestLogProvider.php @@ -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 { @@ -41,7 +41,7 @@ public function getBrowserLogs(): array { $driver = $this->session->getDriver(); - if (!($driver instanceof Selenium2Driver) || !$this->session->isStarted()) { + if (!($driver instanceof WebDriver) || !$this->session->isStarted()) { return []; } @@ -49,13 +49,17 @@ public function getBrowserLogs(): array 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();