private void ParseByDetails(LocatorTypeEnum locatorType, string locator) { By parsedBy = null; switch (locatorType) { case LocatorTypeEnum.Id: parsedBy = By.Id(locator); break; case LocatorTypeEnum.ClassName: parsedBy = By.ClassName(locator); break; case LocatorTypeEnum.Css: parsedBy = By.CssSelector(locator); break; case LocatorTypeEnum.Name: parsedBy = By.Name(locator); break; case LocatorTypeEnum.XPath: parsedBy = By.XPath(locator); break; case LocatorTypeEnum.PartialLinkText: parsedBy = By.PartialLinkText(locator); break; //The locator is ignored with this locator case LocatorTypeEnum.NoLocator: parsedBy = By.TagName(locator); break; default: throw new InvalidOperationException("Unhandled LocatorTypeEnum parsed in WebElementLocator "); } this.ByLocator = parsedBy; }
public WebElementLocatorAttribute(LocatorTypeEnum locatorType, string locator) { this.ParseByDetails(locatorType, locator); }