Skip to content

Commit 7cb5885

Browse files
committed
Add a headless parameter to Start-SeChrome
Added a headless Parameter to simplify starting chrome in headless mode.
1 parent 0230ad0 commit 7cb5885

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Selenium.psm1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ function Start-SeChrome {
77
[array]$Arguments,
88
[switch]$HideVersionHint,
99
[System.IO.FileInfo]$DefaultDownloadPath,
10-
[bool]$DisableBuiltInPDFViewer=$true
10+
[bool]$DisableBuiltInPDFViewer=$true,
11+
[bool]$Headless=$false
1112
)
1213

1314
$Chrome_Options = New-Object -TypeName "OpenQA.Selenium.Chrome.ChromeOptions"
@@ -21,6 +22,10 @@ function Start-SeChrome {
2122
$Chrome_Options.AddUserProfilePreference('plugins', @{'always_open_pdf_externally' = $true;})
2223
}
2324

25+
if ($Headless) {
26+
$Chrome_Options.AddArguments('headless')
27+
}
28+
2429
if ($Arguments) {
2530
$Chrome_Options.AddArguments($Arguments)
2631
}

Selenium.tests.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ Describe "Start-SeChrome" {
77
}
88
}
99

10+
Describe "Start-SeChrome headless" {
11+
Context "Should Start Chrome Driver in headless mode" {
12+
$Driver = Start-SeChrome -Headless $true
13+
Stop-SeDriver $Driver
14+
}
15+
}
16+
1017
Describe "Start-SeFirefox" {
1118
Context "Should Start Firefox Driver" {
1219
$Driver = Start-SeFirefox

0 commit comments

Comments
 (0)