I'm using Selenium with PowerShell to launch a dashboard display in Internet Explorer on a large monitor in the office. I initiate it like so:
$seleniumOptions = New-Object OpenQA.Selenium.IE.InternetExplorerOptions
$seleniumOptions.BrowserCommandLineArguments = "-k"
$seleniumDriver = New-Object OpenQA.Selenium.IE.InternetExplorerDriver($seleniumOptions)
It all works great. However when it launches an instance of IEDriverServer.exe you see a black console window with debug output. Is there a way to hide this black console window from view?
Thanks.
UPDATE - with a little help from this, mklement0 and JimEvans I've managed to cobble this together and it appears to work - thanks all:
Either (pre-PowerShell 5)
New-Variable -Name IEDS -Value ([OpenQA.Selenium.IE.InternetExplorerDriverService])
$defaultservice = $IEDS::CreateDefaultService()
Or (PowerShell 5)
$defaultservice = [OpenQA.Selenium.IE.InternetExplorerDriverService]::CreateDefaultService()
and then
$defaultservice.HideCommandPromptWindow = $true;
and finally
$seleniumDriver = New-Object OpenQA.Selenium.IE.InternetExplorerDriver -ArgumentList @($defaultservice, $seleniumOptions)
The .NET bindings provide a way to hide the command prompt window spawned by IEDerverServer.exe. Code demonstrating that in C# is listed below. Translating that for use with PowerShell is left as an exercise for the reader.
var service = InternetExplorerDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;
// Set IE driver options here
var options = new InternetExplorerOptions();
IWebDriver driver = new InternetExplorerDriver(service, options);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With