I would like to start the Chromium Edge selenium webdriver in application mode using powershell.
This is how you do it from the powershell command line without the selenium webdriver:
& "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --app="https://stackoverflow.com"
This is what I've tried so far but it doesn't seem to work. Specifically, the Chromium Edge webdriver window starts up, but not in application mode.
$optionSettings = @{
BrowserName = ''
BinaryLocation = $pathToDriver
}
$options = New-Object -TypeName OpenQA.Selenium.Chrome.ChromeOptions -Property $optionSettings
$options.addArgument("app='https://stackoverflow.com'")
$service = [OpenQA.Selenium.Chrome.ChromeDriverService]::CreateDefaultService($pathToDriver, 'msedgedriver.exe')
$driver = New-Object -TypeName OpenQA.Selenium.Chrome.ChromeDriver -ArgumentList $service,$options
I've also tried substituting the following for the addArgument:
$options.addArgument("app=https://stackoverflow.com")
$options.addArgument("--app='https://stackoverflow.com'")
$options.addArgument("--app=https://stackoverflow.com")
Any ideas?
CodePudding user response:
First, if you need to start Chromium Edge via Webdriver, you need to use EdgeDriver
instead of ChromeDriver. Secondly, you need to use Selenium 4
webdriver or above.
Here is a simple demo, and it works well:
[System.Reflection.Assembly]::LoadFrom("E:\Selenium\WebDriver.dll")
$options = New-Object OpenQA.Selenium.Edge.EdgeOptions
$options.addArguments("--app=https://stackoverflow.com")
#$options.AcceptInsecureCertificates = $True
$driver = New-Object OpenQA.Selenium.Edge.EdgeDriver("C:\Users\Administrator\Desktop\",$options)
#$driver.Url = "https://stackoverflow.com"
Note: Modify the path parameters according to your own situation.