在 PowerShell 中设置变量和静默输出
Set a variable and silence output in PowerShell
我在 POWERSHELL 上有这个程序:
$ChromeOptions = New-Object OpenQA.Selenium.Chrome.ChromeOptions
$ChromeOptions.addargument('--kiosk-printing')
$driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions)
终端中的最后一行 return 许多信息(ChromeDriver 已成功启动。DevTools 正在侦听等...)。
我的问题是我想隐藏所有这些消息。
我已经试过了:
1) ($driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions))|Out-Null
2) $driver = (New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions))|Out-Null
3) $driver = [void] (New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions))
4) [void] ($driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions))
5) $driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions) -InformationVariable 'Ignore'
6) $driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions) >$null
还有其他想法吗?谢谢
以下将完全停止显示控制台:
$ChromeService = [OpenQA.Selenium.Chrome.ChromeDriverService]::CreateDefaultService()
$ChromeService.HideCommandPromptWindow = $true
$ChromeOptions = New-Object OpenQA.Selenium.Chrome.ChromeOptions
$ChromeOptions.addargument('--kiosk-printing')
$driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeService,$ChromeOptions)
我在 POWERSHELL 上有这个程序:
$ChromeOptions = New-Object OpenQA.Selenium.Chrome.ChromeOptions
$ChromeOptions.addargument('--kiosk-printing')
$driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions)
终端中的最后一行 return 许多信息(ChromeDriver 已成功启动。DevTools 正在侦听等...)。
我的问题是我想隐藏所有这些消息。
我已经试过了:
1) ($driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions))|Out-Null
2) $driver = (New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions))|Out-Null
3) $driver = [void] (New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions))
4) [void] ($driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions))
5) $driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions) -InformationVariable 'Ignore'
6) $driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions) >$null
还有其他想法吗?谢谢
以下将完全停止显示控制台:
$ChromeService = [OpenQA.Selenium.Chrome.ChromeDriverService]::CreateDefaultService()
$ChromeService.HideCommandPromptWindow = $true
$ChromeOptions = New-Object OpenQA.Selenium.Chrome.ChromeOptions
$ChromeOptions.addargument('--kiosk-printing')
$driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeService,$ChromeOptions)