运行laravel黄昏测试时,cmd显示很多控制台消息,例如:
DevTools listening on ws://127.0.0.1:12802/devtools/browser/dbffc66a-0b29-4149-a1b5-8f20259770c2
[0720/101840.929:INFO:CONSOLE(44479)] "Download the Vue Devtools extension for a better development
experience:
https://github.com/vuejs/vue-devtools", source: http://localhost:8000/js/app.js (44479)
[0720/101840.929:INFO:CONSOLE(44490)] "You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html", source: http://localhost:8000/js/app.js (
44490)
如何防止这种情况?在测试过程中浏览每个页面时都会显示此信息
答案 0 :(得分:0)
这个回复有点晚,但是我现在才想到这个问题。
您可以将参数传递给Chrome驱动程序,以防止控制台记录日志,如下所示。
在Laravel 5.8上
test \ DuskTestCase.php
...
/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
protected function driver()
{
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
'--headless',
'--window-size=1920,1080',
'--log-level=3', // Add this line
'--silent' // Add this line
]);
return RemoteWebDriver::create(
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
)
);
}
...
这将关闭所有控制台消息。