public function assertEmptyBrowserConsole()
    {
        $webDriver = $this->getModule('WebDriver');
        $browserLogEntries = $webDriver->webDriver->manage()->getLog('browser');

        $messages = [];
        foreach ($browserLogEntries as $logEntry) {
            // We fail only on errors. Warnings and info messages are OK.
            if (true === isset($logEntry['level'])
                && true === isset($logEntry['message'])
                && $this->isJSError($logEntry['level'], $logEntry['message'])
            ) {
                // Timestamp is in milliseconds, but date() requires seconds.
                $time = date('H:i:s', (int)($logEntry['timestamp'] / 1000));
                // Append the milliseconds to the end of the time string
                $ms = $logEntry['timestamp'] % 1000;
                $messages[] = "{$time}.{$ms} {$logEntry['level']} - {$logEntry['message']}";
            }
        }
        if (empty($messages)) {
            return;
        }
        $messages = array_merge(['Found following JavaScript errors in the browser console:'], $messages);
        $message = implode(PHP_EOL, $messages);
        $this->fail($message);
    }