Пример #1
0
        public static By SeleniumSelector(ISelector selector)
        {
            switch (selector.SelectorType)
            {
            case SelectorType.Name:
                return(By.Name(selector.SelectorValue));

            case SelectorType.Id:
                return(By.Id(selector.SelectorValue));

            case SelectorType.ElementType:
                return(By.TagName(selector.SelectorValue));

            case SelectorType.LinkText:
                return(By.LinkText(selector.SelectorValue));

            case SelectorType.CssSelector:
                return(By.CssSelector(selector.SelectorValue));

            case SelectorType.XPath:
                return(By.XPath(selector.SelectorValue));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #2
0
        // ************ DATE 10/16/2020 ************
        // All the Builders used till date.
        // ***** IMPORTANT: This Builder return a new class of type By from OpenQA.Selenium
        // ************ --------------- ************
        #region BUILDERS


        /// <summary>
        /// Builds a By object using the enum pass
        /// </summary>
        /// <param name="by">Represents the Enum in Share class.</param>
        /// <param name="value">Value used to find the element.</param>
        /// <param name="element">The element type.</param>
        /// <param name="isWidget">True if it is a widget, false if it is a View.</param>
        public static By BuildBy(Share.By by, Share.Element element, bool isWidget = true)
        {
            var attribute = Misc.BuildElement(isWidget, element);
            By  _by       = null;

            switch (by)
            {
            case Share.By.ClassName:
                _by = By.ClassName(attribute);
                break;

            case Share.By.CssSelector:
                _by = By.CssSelector(attribute);
                break;

            case Share.By.Id:
                _by = By.Id(attribute);
                break;

            case Share.By.LinkText:
                _by = By.LinkText(attribute);
                break;

            case Share.By.Name:
                _by = By.Name(attribute);
                break;

            case Share.By.PartialLinkText:
                _by = By.PartialLinkText(attribute);
                break;

            case Share.By.TagName:
                _by = By.TagName(attribute);
                break;

            case Share.By.XPath:
                _by = By.XPath(attribute);
                break;
            }
            return(_by);
        }