Skip to content

Commit 80d1e3d

Browse files
Larry SongLarry Song
authored andcommitted
new cmdlet 'Wait-SeElementExists' to wait for a element until it presents
1 parent bc39ccf commit 80d1e3d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Selenium.psd1

58 Bytes
Binary file not shown.

Selenium.psm1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,29 @@ function Save-SeScreenshot {
198198
$Screenshot.SaveAsFile($Path, $ImageFormat)
199199
}
200200
}
201+
202+
function Wait-SeElementExists {
203+
param(
204+
$Driver,
205+
$Timeout = 30,
206+
$Id,
207+
$Name
208+
)
209+
if($Id)
210+
{
211+
$TargetElement = [OpenQA.Selenium.By]::Id($Id)
212+
}
213+
elseif($Name)
214+
{
215+
$TargetElement = [OpenQA.Selenium.By]::Name($Name)
216+
}
217+
else
218+
{
219+
throw "Please specify -Id or -Name"
220+
}
221+
$WebDriverWait = New-Object OpenQA.Selenium.Support.UI.WebDriverWait $Driver, ($Timeout * 10000000) # ticks
222+
$Condition = [OpenQA.Selenium.Support.UI.ExpectedConditions]::ElementExists($TargetElement)
223+
$WebDriverWait.Until($Condition)
224+
}
225+
226+

0 commit comments

Comments
 (0)