WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: stanl on March 22, 2018, 05:13:18 PM

Title: ... and while we're on the subject
Post by: stanl on March 22, 2018, 05:13:18 PM
[back to Selenium].

When running a Selenium script with ChromeDriver a cmd prompt pops up as the browser is loaded.  I an trying to disable it with this snippet - script does not error but cmd prompt still displays

Code (WINBATCH) Select

ObjectClrOption("use", 'WebDriver')
_TRUE = ObjectType( "BOOL", @TRUE )
_FALSE = ObjectType( "BOOL", @FALSE )
objBy = ObjectClrNew('OpenQA.Selenium.By')
oSvc = ObjectClrNew('OpenQA.Selenium.Chrome.ChromeDriverService')
oDefa= oSvc.CreateDefaultService()
oDefa.HideCommandPromptWindow = _TRUE
objDriver = ObjectClrNew('OpenQA.Selenium.Chrome.ChromeDriver')


Even the Selenium folks say it is not good practice to hide the command prompt and the hide option was added to appease.  But, I'd like to hide it.
Title: Re: ... and while we're on the subject
Post by: td on March 22, 2018, 08:43:24 PM
Assuming Chrome works like the Firefox driver, you need to pass the service object to the WebDriver object's constructor.  You also need to start the service. Using my previous incomplete example:

Code (winbatch) Select
objService = ObjectClrNew('OpenQA.Selenium.Firefox.FirefoxDriverService')
objService= objService.CreateDefaultService()
objService.HideCommandPromptWindow = ObjectType("bool", -1)
objService.Start()
objDriver = ObjectClrNew('OpenQA.Selenium.Firefox.FirefoxDriver', objService)

Title: Re: ... and while we're on the subject
Post by: stanl on March 23, 2018, 02:58:35 AM
Thanks, worked like a charm.