Skip to content

Commit c399dba

Browse files
authored
Merge pull request #8 from lolSam/master
Support for Chrome Options ie. headless
2 parents e0574c8 + a4c5071 commit c399dba

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,10 @@ $Driver = Start-SeFirefox
4343
Enter-SeUrl https://www.poshud.com -Driver $Driver
4444
$Element = Find-SeElement -Driver $Driver -Id "txtEmail"
4545
Send-SeKeys -Element $Element -Keys "[email protected]"
46+
```
47+
48+
## Run Chrome with options
49+
50+
```powershell
51+
$Driver = Start-SeChrome -Arguments "headless","incognito"
4652
```

Selenium.psm1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
[System.Reflection.Assembly]::LoadFrom("$PSScriptRoot\assemblies\WebDriver.dll")
22
[System.Reflection.Assembly]::LoadFrom("$PSScriptRoot\assemblies\WebDriver.Support.dll")
33
function Start-SeChrome {
4-
New-Object -TypeName "OpenQA.Selenium.Chrome.ChromeDriver"
4+
Param(
5+
[Parameter(Mandatory = $false)]
6+
[array]$Arguments
7+
)
8+
if($Arguments) {
9+
$Chrome_Options = New-Object -TypeName "OpenQA.Selenium.Chrome.ChromeOptions"
10+
$Chrome_Options.AddArguments($Arguments)
11+
}
12+
New-Object -TypeName "OpenQA.Selenium.Chrome.ChromeDriver" -ArgumentList $Chrome_Options
513
}
614

715
function Start-SeFirefox {

assemblies/chromedriver.exe

-59.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)