public static By ClassName(string classNameToFind)
{
if (classNameToFind == null)
{
throw new ArgumentNullException("classNameToFind", "Cannot find elements when the class name expression is null.");
}
if (new Regex(".*\\s+.*").IsMatch(classNameToFind))
{
throw new IllegalLocatorException("Compound class names are not supported. Consider searching for one class name and filtering the results.");
}
By by = new By();
by.findElementMethod =
(ISearchContext context) => ((IFindsByClassName)context).FindElementByClassName(classNameToFind);
by.findElementsMethod =
(ISearchContext context) => ((IFindsByClassName)context).FindElementsByClassName(classNameToFind);
by.description = "By.ClassName[Contains]: " + classNameToFind;
return by;
}