@@ -10,18 +10,21 @@ function Start-SeChrome {
1010 )
1111
1212 $Chrome_Options = New-Object - TypeName " OpenQA.Selenium.Chrome.ChromeOptions"
13+
1314 if ($DefaultDownloadPath ){
1415 Write-Host " Setting Default Download directory: $DefaultDownloadPath "
1516 $Chrome_Options.AddUserProfilePreference (' download' , @ {' default_directory' = $ ($DefaultDownloadPath.FullName ); ' prompt_for_download' = $false ; })
1617 }
18+
1719 if ($DisableBuiltInPDFViewer ){
1820 $Chrome_Options.AddUserProfilePreference (' plugins' , @ {' always_open_pdf_externally' = $true ;})
1921 }
20- if ($Arguments ) {
22+
23+ if ($Arguments ) {
2124 $Chrome_Options.AddArguments ($Arguments )
2225 }
23- if ( ! $HideVersionHint )
24- {
26+
27+ if ( ! $HideVersionHint ) {
2528 Write-Host " Download the right chromedriver from 'http://chromedriver.chromium.org/downloads'" - ForegroundColor Yellow
2629 }
2730 New-Object - TypeName " OpenQA.Selenium.Chrome.ChromeDriver" - ArgumentList $Chrome_Options
@@ -63,6 +66,8 @@ function Find-SeElement {
6366 $Driver ,
6467 [Parameter ()]
6568 $Element ,
69+ [Parameter (ParameterSetName = " ByCss" )]
70+ $Css ,
6671 [Parameter (ParameterSetName = " ByName" )]
6772 $Name ,
6873 [Parameter (ParameterSetName = " ById" )]
@@ -124,7 +129,7 @@ function Find-SeElement {
124129 if ($PSCmdlet.ParameterSetName -eq " ByXPath" ) {
125130 $Target.FindElements ([OpenQA.Selenium.By ]::XPath($XPath ))
126131 }
127-
132+
128133 if ($PSCmdlet.ParameterSetName -eq " ByCss" ) {
129134 $Target.FindElements ([OpenQA.Selenium.By ]::CssSelector($Css ))
130135 }
@@ -139,11 +144,12 @@ function Invoke-SeClick {
139144 [Switch ]$JavaScriptClick ,
140145 [Parameter ()]
141146 $Driver
142- )
147+ )
143148
144149 if ($JavaScriptClick ) {
145150 $Driver.ExecuteScript (" arguments[0].click()" , $Element )
146- } else {
151+ }
152+ else {
147153 $Element.Click ()
148154 }
149155
@@ -152,16 +158,16 @@ function Invoke-SeClick {
152158
153159function Get-SeKeys {
154160
155- [OpenQA.Selenium.Keys ] | Get-Member - MemberType Property - Static | Select-Object - Property Name, @ {N = " ObjectString" ; E = {" [OpenQA.Selenium.Keys]::$ ( $_.Name ) " } }
161+ [OpenQA.Selenium.Keys ] | Get-Member - MemberType Property - Static | Select-Object - Property Name, @ {N = " ObjectString" ; E = { " [OpenQA.Selenium.Keys]::$ ( $_.Name ) " } }
156162}
157163
158164function Send-SeKeys {
159165 param ([OpenQA.Selenium.IWebElement ]$Element , [string ]$Keys )
160166
161- foreach ($Key in @ (Get-SeKeys ).Name)
162- {
167+ foreach ($Key in @ (Get-SeKeys ).Name) {
163168 $Keys = $Keys -replace " {{$Key }}" , [OpenQA.Selenium.Keys ]::$Key
164169 }
170+
165171 $Element.SendKeys ($Keys )
166172}
167173
@@ -180,16 +186,16 @@ function Remove-SeCookie {
180186function Set-SeCookie {
181187 param ($Driver , $name , $value )
182188
183- $cookie = New-Object - TypeName OpenQA.Selenium.Cookie - ArgumentList $Name , $value
189+ $cookie = New-Object - TypeName OpenQA.Selenium.Cookie - ArgumentList $Name , $value
184190
185191 $Driver.Manage ().Cookies.AddCookie($cookie )
186192}
187193
188194function Get-SeElementAttribute {
189195 param (
190- [Parameter (ValueFromPipeline = $true , Mandatory = $true )]
196+ [Parameter (ValueFromPipeline = $true , Mandatory = $true )]
191197 [OpenQA.Selenium.IWebElement ]$Element ,
192- [Parameter (Mandatory = $true )]
198+ [Parameter (Mandatory = $true )]
193199 [string ]$Attribute
194200 )
195201
@@ -204,7 +210,8 @@ function Invoke-SeScreenshot {
204210 $Screenshot = [OpenQA.Selenium.Support.Extensions.WebDriverExtensions ]::TakeScreenshot($Driver )
205211 if ($AsBase64EncodedString ) {
206212 $Screenshot.AsBase64EncodedString
207- } else {
213+ }
214+ else {
208215 $Screenshot
209216 }
210217}
@@ -218,9 +225,9 @@ function Save-SeScreenshot {
218225 [Parameter ()]
219226 [OpenQA.Selenium.ScreenshotImageFormat ]$ImageFormat = [OpenQA.Selenium.ScreenshotImageFormat ]::Png)
220227
221- Process {
222- $Screenshot.SaveAsFile ($Path , $ImageFormat )
223- }
228+ Process {
229+ $Screenshot.SaveAsFile ($Path , $ImageFormat )
230+ }
224231}
225232
226233function Wait-SeElementExists {
@@ -232,12 +239,10 @@ function Wait-SeElementExists{
232239 $TagName ,
233240 $ClassName
234241 )
235- if ($Id )
236- {
242+ if ($Id ) {
237243 $TargetElement = [OpenQA.Selenium.By ]::Id($Id )
238244 }
239- elseif ($Name )
240- {
245+ elseif ($Name ) {
241246 $TargetElement = [OpenQA.Selenium.By ]::Name($Name )
242247 }
243248 elseif ($TagName )
0 commit comments