@@ -8,7 +8,7 @@ elseif($IsMacOS){
88 $AssembliesPath = " $PSScriptRoot /assemblies/macos"
99}
1010
11- # Grant Execution permission to assemblies on Linux and MacOS
11+ # Grant Execution permission to assemblies on Linux and MacOS
1212if ($IsLinux -or $IsMacOS ){
1313 # Check if powershell is NOT running as root
1414 $AssemblieFiles = Get-ChildItem - Path $AssembliesPath | Where-Object {$_.Name -eq ' chromedriver' -or $_.Name -eq ' geckodriver' }
@@ -62,7 +62,7 @@ function Start-SeChrome {
6262 }
6363 PROCESS {
6464 $Chrome_Options = New-Object - TypeName " OpenQA.Selenium.Chrome.ChromeOptions"
65-
65+
6666 if ($DefaultDownloadPath ){
6767 Write-Verbose " Setting Default Download directory: $DefaultDownloadPath "
6868 $Chrome_Options.AddUserProfilePreference (' download' , @ {' default_directory' = $ ($DefaultDownloadPath.FullName ); ' prompt_for_download' = $false ; })
@@ -71,11 +71,11 @@ function Start-SeChrome {
7171 Write-Verbose " Setting Profile directory: $ProfileDirectoryPath "
7272 $Chrome_Options.AddArgument (" user-data-dir=$ProfileDirectoryPath " )
7373 }
74-
74+
7575 if ($DisableBuiltInPDFViewer ){
7676 $Chrome_Options.AddUserProfilePreference (' plugins' , @ {' always_open_pdf_externally' = $true ;})
7777 }
78-
78+
7979 if ($Headless ) {
8080 $Chrome_Options.AddArguments (' headless' )
8181 }
@@ -97,7 +97,7 @@ function Start-SeChrome {
9797 $Chrome_Options.AddArguments ($Argument )
9898 }
9999 }
100-
100+
101101 if (! $HideVersionHint ) {
102102 Write-Verbose " Download the right chromedriver from 'http://chromedriver.chromium.org/downloads'"
103103 }
@@ -106,22 +106,14 @@ function Start-SeChrome {
106106 $Driver = New-Object - TypeName " OpenQA.Selenium.Chrome.ChromeDriver" - ArgumentList $AssembliesPath , $Chrome_Options
107107 }
108108 else {
109- $Driver = New-Object - TypeName " OpenQA.Selenium.Chrome.ChromeDriver" - ArgumentList $Chrome_Options
109+ $Driver = New-Object - TypeName " OpenQA.Selenium.Chrome.ChromeDriver" - ArgumentList $Chrome_Options
110110 }
111111
112112 if ($Minimized ){
113113 $driver.Manage ().Window.Minimize();
114114
115115 }
116116
117- if ($Headless -and $DefaultDownloadPath ) {
118- $CmdParams = New-Object ' system.collections.generic.dictionary[[System.String],[System.Object]]]'
119- $CmdParams.Add (' behavior' , ' allow' )
120- $CmdParams.Add (' downloadPath' , $DefaultDownloadPath.FullName )
121-
122- $Driver.ExecuteChromeCommand (' Page.setDownloadBehavior' , $CmdParams )
123- }
124-
125117 if ($StartURL ){
126118 Enter-SeUrl - Driver $Driver - Url $StartURL
127119 }
@@ -134,7 +126,7 @@ function Start-SeChrome {
134126function Start-SeInternetExplorer {
135127 $InternetExplorer_Options = New-Object - TypeName " OpenQA.Selenium.IE.InternetExplorerOptions"
136128 $InternetExplorer_Options.IgnoreZoomLevel = $true
137- New-Object - TypeName " OpenQA.Selenium.IE.InternetExplorerDriver" - ArgumentList $InternetExplorer_Options
129+ New-Object - TypeName " OpenQA.Selenium.IE.InternetExplorerDriver" - ArgumentList $InternetExplorer_Options
138130}
139131
140132function Start-SeEdge {
@@ -169,7 +161,7 @@ function Start-SeFirefox {
169161}
170162
171163function Stop-SeDriver {
172- param ($Driver )
164+ param ($Driver )
173165
174166 $Driver.Dispose ()
175167}
@@ -230,7 +222,7 @@ function Find-SeElement {
230222 if ($PSCmdlet.ParameterSetName -eq " ById" ) {
231223 $TargetElement = [OpenQA.Selenium.By ]::Id($Id )
232224 }
233-
225+
234226 if ($PSCmdlet.ParameterSetName -eq " ByLinkText" ) {
235227 $TargetElement = [OpenQA.Selenium.By ]::LinkText($LinkText )
236228 }
@@ -246,15 +238,15 @@ function Find-SeElement {
246238 if ($PSCmdlet.ParameterSetName -eq " ByTagName" ) {
247239 $TargetElement = [OpenQA.Selenium.By ]::TagName($TagName )
248240 }
249-
241+
250242 if ($PSCmdlet.ParameterSetName -eq " ByXPath" ) {
251243 $TargetElement = [OpenQA.Selenium.By ]::XPath($XPath )
252244 }
253245
254246 if ($PSCmdlet.ParameterSetName -eq " ByCss" ) {
255247 $TargetElement = [OpenQA.Selenium.By ]::CssSelector($Css )
256248 }
257-
249+
258250 $WebDriverWait = New-Object - TypeName OpenQA.Selenium.Support.UI.WebDriverWait($Driver , (New-TimeSpan - Seconds $Timeout ))
259251 $Condition = [OpenQA.Selenium.Support.UI.ExpectedConditions ]::ElementExists($TargetElement )
260252 $WebDriverWait.Until ($Condition )
@@ -287,7 +279,7 @@ function Find-SeElement {
287279 if ($PSCmdlet.ParameterSetName -eq " ByXPath" ) {
288280 $Target.FindElements ([OpenQA.Selenium.By ]::XPath($XPath ))
289281 }
290-
282+
291283 if ($PSCmdlet.ParameterSetName -eq " ByCss" ) {
292284 $Target.FindElements ([OpenQA.Selenium.By ]::CssSelector($Css ))
293285 }
@@ -315,17 +307,17 @@ function Invoke-SeClick {
315307}
316308
317309function Get-SeKeys {
318-
310+
319311 [OpenQA.Selenium.Keys ] | Get-Member - MemberType Property - Static | Select-Object - Property Name, @ {N = " ObjectString" ; E = { " [OpenQA.Selenium.Keys]::$ ( $_.Name ) " } }
320312}
321313
322314function Send-SeKeys {
323315 param ([OpenQA.Selenium.IWebElement ]$Element , [string ]$Keys )
324-
316+
325317 foreach ($Key in @ (Get-SeKeys ).Name) {
326318 $Keys = $Keys -replace " {{$Key }}" , [OpenQA.Selenium.Keys ]::$Key
327319 }
328-
320+
329321 $Element.SendKeys ($Keys )
330322}
331323
@@ -352,7 +344,7 @@ function Remove-SeCookie {
352344
353345function Set-SeCookie {
354346 param (
355- [ValidateNotNull ()]$Driver ,
347+ [ValidateNotNull ()]$Driver ,
356348 [string ]$Name ,
357349 [string ]$Value ,
358350 [string ]$Path ,
@@ -368,7 +360,7 @@ function Set-SeCookie {
368360 Cookie(String, String, String, Nullable<DateTime>)
369361 Initializes a new instance of the Cookie class with a specific name, value, path and expiration date.
370362 Cookie(String, String, String, String, Nullable<DateTime>)
371- Initializes a new instance of the Cookie class with a specific name, value, domain, path and expiration date.
363+ Initializes a new instance of the Cookie class with a specific name, value, domain, path and expiration date.
372364 #>
373365 Begin {
374366 if ($ExpiryDate -ne $null -and $ExpiryDate.GetType ().Name -ne ' DateTime' ){
@@ -420,7 +412,7 @@ function Get-SeElementAttribute {
420412
421413 Process {
422414 $Element.GetAttribute ($Attribute )
423- }
415+ }
424416}
425417
426418function Invoke-SeScreenshot {
@@ -456,7 +448,7 @@ function Get-SeWindow {
456448
457449 Process {
458450 $Driver.WindowHandles
459- }
451+ }
460452}
461453
462454function Switch-SeWindow {
@@ -467,5 +459,5 @@ function Switch-SeWindow {
467459
468460 Process {
469461 $Driver.SwitchTo ().Window($Window )| Out-Null
470- }
462+ }
471463}
0 commit comments