public static CssSelector ( string cssSelectorToFind ) : |
||
cssSelectorToFind | string | The CSS selector to find. |
return |
public static By CssSelector(string cssSelectorToFind)
{
if (cssSelectorToFind == null)
{
throw new ArgumentNullException("cssSelectorToFind", "Cannot find elements when name CSS selector is null.");
}
By by = new By();
by.findElementMethod =
(ISearchContext context) => ((IFindsByCssSelector)context).FindElementByCssSelector(cssSelectorToFind);
by.findElementsMethod =
(ISearchContext context) => ((IFindsByCssSelector)context).FindElementsByCssSelector(cssSelectorToFind);
by.description = "By.CssSelector: " + cssSelectorToFind;
return by;
}
/// <summary> /// Click the 'Edit' button for a position category /// </summary> /// <param name="categoryName">The name of the category to edit</param> public void EditPositionCategory(string categoryName = null) { // if the category isnt specified, find the first category in the list if (String.IsNullOrWhiteSpace(categoryName)) { categoryName = _driver.FindElement(By.CssSelector("#maintbl > tbody > #rowNbr0 > td > b")).Text; } ((IJavaScriptExecutor)_driver).ExecuteScript("EditPositionCategory('" + categoryName + "')"); }