... and while we're on the subject

Started by stanl, March 22, 2018, 05:13:18 PM

Previous topic - Next topic

stanl

[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.

td

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)

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl