Skip to content

Commit

Permalink
Add Exists property to Element class that catches the timeout excepti…
Browse files Browse the repository at this point in the history
…on and returns false.
  • Loading branch information
tnypxl committed May 5, 2020
1 parent 630f8ec commit af91335
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Basin/Basin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<PackageId>BasinFramework</PackageId>
<PackageVersion>0.0.6</PackageVersion>
<PackageVersion>0.0.7</PackageVersion>
<Title>Arik Jones</Title>
<Authors>BasinFramework</Authors>
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks>
Expand All @@ -14,7 +14,7 @@
<RepositoryType>Git</RepositoryType>
<PackageTags>selenium, browser, automation, framework</PackageTags>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>TBD</PackageReleaseNotes>
<PackageReleaseNotes>Add Exists property that catches the timeout so that we can return false. </PackageReleaseNotes>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<OutputType>Library</OutputType>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Expand Down
15 changes: 15 additions & 0 deletions Basin/Selenium/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ private IWebElement Locate
}
}

public bool Exists
{
get
{
try
{
return Current.Displayed;
}
catch (WebDriverTimeoutException)
{
return false;
}
}
}

private IWebElement Current => Locate ?? throw new NullReferenceException("Element could not located because it was null");

private IWebElement CurrentParent => _parentElement ?? throw new NullReferenceException("Parent element could not be located because it was null");
Expand Down

0 comments on commit af91335

Please sign in to comment.