powershellseleniumterminalsilent

Set a variable and silence output in PowerShell


I have this program on POWERSHELL:

$ChromeOptions = New-Object OpenQA.Selenium.Chrome.ChromeOptions 
$ChromeOptions.addargument('--kiosk-printing')
$driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions)

This last line return in the terminal many informations ( ChromeDriver was started successfully. DevTools listening on etc ...).

My problem is that I want to hide all of this message.

I have already tried :

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

Any other ideas ? Thanks


Solution

  • The following will stop the console appearing entirely:

    $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)