コード例 #1
0
        public static IWebElement CreateWebElementProxy(WebElementDefinition element)
        {
            By   elementBy      = ConvertLocatorSearchMethodToBy(element.HowToSearch, element.Locator);
            bool shouldBecached = false;

            var driverParam = GetDriver();
            var bysParam    = new By[] { elementBy };

            var elementProxy = new WebElementProxy(driverParam, bysParam, shouldBecached);

            return(elementProxy);
        }
コード例 #2
0
        public WebElementDefinition Clone()
        {
            var clone = new WebElementDefinition()
            {
                Name                 = Name,
                HtmlId               = HtmlId,
                Locator              = Locator,
                CssSelector          = CssSelector,
                Xpath                = Xpath,
                HowToSearch          = HowToSearch,
                HtmlTag              = HtmlTag,
                ReturnsCollection    = ReturnsCollection,
                Arg1                 = Arg1,
                Arg2                 = Arg2,
                Arg3                 = Arg3,
                AllHtmlTagProperties = new WebElementHtmlAttributes(),
                AlternativeFindBys   = null,
                frame                = frame,
            };


            foreach (var entry in AllHtmlTagProperties)
            {
                clone.AllHtmlTagProperties.Add(entry.Key, entry.Value);
            }


            List <WebElementLocator> clonedfindBys = new List <WebElementLocator>();

            foreach (var entry in AlternativeFindBys)
            {
                // TODO: Replace properties initializer with constructor to handle data structure change in compile time
                clonedfindBys.Add(new WebElementLocator()
                {
                    HowToSearch = entry.HowToSearch,
                    Locator     = entry.Locator,
                    CssSelector = entry.CssSelector,
                });
            }

            clone.AlternativeFindBys = clonedfindBys.ToArray();

            return(clone);
        }