Skip to content

Commit

Permalink
Added web element extension to determine if an element has a specific…
Browse files Browse the repository at this point in the history
… class name.
  • Loading branch information
jamesmcroft committed Sep 25, 2021
1 parent 7d459bb commit da1a43a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Legerity.Web/Extensions/IWebElementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,16 @@ public static string GetInnerHtml(this IWebElement element)
{
return element.GetAttribute("innerHTML");
}

/// <summary>
/// Determines whether the specified <see cref="IWebElement"/> has the specified <paramref name="className">class</paramref>.
/// </summary>
/// <param name="element">The <see cref="IWebElement"/> to check.</param>
/// <param name="className">The name of the class the element should have.</param>
/// <returns>True if the element has the class; otherwise, false.</returns>
public static bool HasClass(this IWebElement element, string className)
{
return element.GetAttribute("class").Contains(className);
}
}
}

0 comments on commit da1a43a

Please sign in to comment.