Skip to content

Commit 6549e13

Browse files
Larry SongLarry Song
authored andcommitted
Add a new cmdlet 'Get-SeKeys' to list supported keys, update 'Send-SeKeys' cmdlet to support '{{KeyName}}' format, e.g. {{Enter}}
1 parent 5028eec commit 6549e13

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Selenium.psd1

38 Bytes
Binary file not shown.

Selenium.psm1

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33
function Start-SeChrome {
44
Param(
55
[Parameter(Mandatory = $false)]
6-
[array]$Arguments
6+
[array]$Arguments,
7+
[switch]$HideVersionHint
78
)
89
if($Arguments) {
910
$Chrome_Options = New-Object -TypeName "OpenQA.Selenium.Chrome.ChromeOptions"
1011
$Chrome_Options.AddArguments($Arguments)
1112
}
13+
if(!$HideVersionHint)
14+
{
15+
Write-Host "Download the right chromedriver from 'http://chromedriver.chromium.org/downloads'" -ForegroundColor Yellow
16+
}
1217
New-Object -TypeName "OpenQA.Selenium.Chrome.ChromeDriver" -ArgumentList $Chrome_Options
1318
}
1419

@@ -121,9 +126,18 @@ function Invoke-SeClick {
121126

122127
}
123128

129+
function Get-SeKeys {
130+
131+
[OpenQA.Selenium.Keys] | Get-Member -MemberType Property -Static | Select-Object -Property Name
132+
}
133+
124134
function Send-SeKeys {
125135
param([OpenQA.Selenium.IWebElement]$Element, [string]$Keys)
126-
136+
137+
foreach($Key in @(Get-SeKeys).Name)
138+
{
139+
$Keys = $Keys -replace "{{$Key}}", [OpenQA.Selenium.Keys]::$Key
140+
}
127141
$Element.SendKeys($Keys)
128142
}
129143

0 commit comments

Comments
 (0)