当前位置: 首页>>代码示例>>C#>>正文


C# ISearchContext.FindElements方法代码示例

本文整理汇总了C#中ISearchContext.FindElements方法的典型用法代码示例。如果您正苦于以下问题:C# ISearchContext.FindElements方法的具体用法?C# ISearchContext.FindElements怎么用?C# ISearchContext.FindElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISearchContext的用法示例。


在下文中一共展示了ISearchContext.FindElements方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindAll

 private static IEnumerable<IWebElement> FindAll(ISearchContext iFind, ByEx byEx, int retries, int milliseconds)
 {
     var elements = byEx.FilterElements(iFind.FindElements(byEx.By));
     while ((retries > 0) && elements.Count() == 0)
     {
         Thread.Sleep(milliseconds);
         elements = byEx.FilterElements(iFind.FindElements(byEx.By));
         retries--;
     }
     return elements;
 }
开发者ID:Duduosun,项目名称:SpecFlow.Extensions,代码行数:11,代码来源:ISearchContextExtension.cs

示例2: DoFind

 private static IEnumerable<IWebElement> DoFind(ISearchContext context, string searchText)
 {
     foreach (var label in context.FindElements(By.XPath(".//label[text() = " + Utility.XPathString(searchText) + "]")))
     {
         var forAttribute = label.GetAttribute("for");
         if (forAttribute != null)
         {
             foreach (var e in context.FindElements(By.Id(forAttribute)))
                 yield return e;
         }
         else
         {
             foreach (var e in label.FindElements(By.XPath("./following-sibling::*[1]")))
             {
                 if (e.TagName == "select" || e.TagName == "textarea" || (e.TagName == "input" && e.GetAttribute("type") != "hidden"))
                     yield return e;
             }
         }
     }
 }
开发者ID:stuartleeks,项目名称:BrowserBoss,代码行数:20,代码来源:FindByLabel.cs

示例3: FindElements

        public override ReadOnlyCollection<IWebElement> FindElements(ISearchContext context)
        {
            List<IWebElement> result = new List<IWebElement>();
            IEnumerable<By> bys = GetReturnRelevantBys(context);

            foreach (var by in bys)
            {
                ReadOnlyCollection<IWebElement> list = context.FindElements(by);
                result.AddRange(list);
            }

            return result.AsReadOnly();
        }
开发者ID:trbnb,项目名称:appium-dotnet-driver,代码行数:13,代码来源:ContentMappedBy.cs

示例4: EnterData

        public void EnterData(ISearchContext context, IWebElement element, object data)
        {
            _searchContext = context;

            var textbox = FindTextbox(context, element);

            var text = (string)data;

            new TextboxElementHandler().EnterData(context, textbox, text);

            Wait.Until(() => context.FindElements(MenuItemSelector).Any());

            var links = context.FindElements(MenuItemSelector);
            var link = links.FirstOrDefault(x => x.Text == text);
            StoryTellerAssert.Fail(link == null, () =>
            {
                string availableItems = links.Select(x => x.Text).Join(", ");
                return "Unable to find drop down item with text {0}, available items were {1}"
                    .ToFormat(text, availableItems);
            });

            Retry.Twice(() => link.Click());
        }
开发者ID:DarthFubuMVC,项目名称:FubuMVC.AutoComplete,代码行数:23,代码来源:AutoCompleteHandler.cs

示例5: TryFind

        /// <summary>
        /// Finds all matching elements, searching child iframes if no matches were found. Only returns results from the first finder that returns results. Does not throw exceptions; an empty enumeration is returned if any errors occur.
        /// </summary>
        /// <param name="this">The finders.</param>
        /// <param name="webDriver">The web driver, representing the top-level context of this search.</param>
        /// <param name="context">The context of the search. All results should be within this context.</param>
        /// <param name="searchText">The search string used to match the elements.</param>
        public static IReadOnlyCollection<IWebElement> TryFind(this IReadOnlyCollection<IFind> @this, IWebDriver webDriver, ISearchContext context, string searchText)
        {
            // First, return all the normal matches.
            webDriver.SwitchTo().DefaultContent();
            var result = @this.TryFind(context, searchText);
            if (result.Count != 0)
                return result;

            // If more results are required, then search the iframes.
            foreach (var iframe in context.FindElements(By.TagName("iframe")))
            {
                webDriver.SwitchTo().Frame(iframe);
                var html = webDriver.FindElement(By.TagName("html"));
                result = @this.TryFind(webDriver, html, searchText);
                if (result.Count != 0)
                    return result;
            }

            return result;
        }
开发者ID:stuartleeks,项目名称:BrowserBoss,代码行数:27,代码来源:FindExtensions.cs

示例6: LocateElements

        /// <summary>
        /// Locates a list of elements using the given <see cref="ISearchContext"/> and list of <see cref="By"/> criteria.
        /// </summary>
        /// <param name="searchContext">The <see cref="ISearchContext"/> object within which to search for elements.</param>
        /// <param name="bys">The list of methods by which to search for the elements.</param>
        /// <returns>An list of all elements which match the desired criteria.</returns>
        public ReadOnlyCollection<IWebElement> LocateElements(ISearchContext searchContext, IEnumerable<By> bys)
        {
            if (searchContext == null)
            {
                throw new ArgumentNullException("searchContext", "searchContext may not be null");
            }

            if (bys == null)
            {
                throw new ArgumentNullException("bys", "List of criteria may not be null");
            }

            List<IWebElement> collection = new List<IWebElement>();
            foreach (var by in bys)
            {
                ReadOnlyCollection<IWebElement> list = searchContext.FindElements(by);
                collection.AddRange(list);
            }

            return collection.AsReadOnly();
        }
开发者ID:BogdanLivadariu,项目名称:selenium,代码行数:27,代码来源:DefaultElementLocatorFactory.cs

示例7: FindElements

        public override ReadOnlyCollection<IWebElement> FindElements(ISearchContext context)
        {
            List<IWebElement> result = new List<IWebElement>();
            IEnumerable<By> bys = GetReturnRelevantBys(context);

            foreach (var by in bys)
            {
                try
                {
                    ReadOnlyCollection<IWebElement> list = context.FindElements(by);
                    result.AddRange(list);
                }
                catch (Exception e)
                {
                    if (IsInvalidSelectorRootCause(e))
                    {
                        continue;
                    }
                    throw e;
                }
            }

            return result.AsReadOnly();
        }
开发者ID:jonstoneman,项目名称:appium-dotnet-driver,代码行数:24,代码来源:ContentMappedBy.cs

示例8:

 IReadOnlyCollection<IWebElement> IFind.Find(ISearchContext context, string searchText)
 {
     return context.FindElements(ByJQuery.CssSelector(searchText));
 }
开发者ID:stuartleeks,项目名称:BrowserBoss,代码行数:4,代码来源:FindByJQueryCss.cs

示例9: LocateElements

        /// <summary>
        /// Locates a list of elements using the given <see cref="ISearchContext"/> and list of <see cref="By"/> criteria.
        /// </summary>
        /// <param name="searchContext">The <see cref="ISearchContext"/> object within which to search for elements.</param>
        /// <param name="bys">The list of methods by which to search for the elements.</param>
        /// <returns>An list of all elements which match the desired criteria.</returns>
        public ReadOnlyCollection<IWebElement> LocateElements(ISearchContext searchContext, IEnumerable<By> bys)
        {
            if (searchContext == null)
            {
                throw new ArgumentNullException("searchContext", "searchContext may not be null");
            }

            if (bys == null)
            {
                throw new ArgumentNullException("bys", "List of criteria may not be null");
            }

            List<IWebElement> collection = new List<IWebElement>();
            DateTime endTime = DateTime.Now.Add(this.timeout);
            bool timeoutReached = DateTime.Now > endTime;
            while (!timeoutReached)
            {
                foreach (var by in bys)
                {
                    ReadOnlyCollection<IWebElement> list = searchContext.FindElements(by);
                    collection.AddRange(list);
                }

                timeoutReached = collection.Count == 0 && DateTime.Now > endTime;
                if (!timeoutReached)
                {
                    Thread.Sleep(this.pollingInterval);
                }
            }

            return collection.AsReadOnly();
        }
开发者ID:JacquesBonet,项目名称:selenium-1,代码行数:38,代码来源:RetryingElementLocatorFactory.cs

示例10: WhereAHeaderMatches

 private bool WhereAHeaderMatches(ISearchContext e, string locator)
 {
     return e.FindElements(By.XPath("./*")).Any(h => headerTags.Contains(h.TagName) && textMatcher.TextMatches(h, locator));
 }
开发者ID:afinzel,项目名称:coypu,代码行数:4,代码来源:SectionFinder.cs

示例11:

 IReadOnlyCollection<IWebElement> IFind.Find(ISearchContext context, string searchText)
 {
     return context.FindElements(By.XPath(".//*[text() = " + Utility.XPathString(searchText) + "]"));
 }
开发者ID:stuartleeks,项目名称:BrowserBoss,代码行数:4,代码来源:FindByText.cs

示例12:

 IReadOnlyCollection<IWebElement> IFind.Find(ISearchContext context, string searchText)
 {
     return context.FindElements(By.XPath(searchText));
 }
开发者ID:stuartleeks,项目名称:BrowserBoss,代码行数:4,代码来源:FindByXPath.cs

示例13: GetDropDownListContent

 private static List<string> GetDropDownListContent(ISearchContext selectDocumentTypeDropDown)
 {
     return selectDocumentTypeDropDown.FindElements(By.TagName("option")).Select(option => option.Text).ToList();
 }
开发者ID:affecto,项目名称:dotnet-Testing.UI.Selenium,代码行数:4,代码来源:WebHostDriver.cs

示例14:

 IReadOnlyCollection<IWebElement> IFind.Find(ISearchContext context, string searchText)
 {
     return context.FindElements(By.CssSelector("*[value=" + Utility.CssString(searchText) + "]"));
 }
开发者ID:stuartleeks,项目名称:BrowserBoss,代码行数:4,代码来源:FindByValue.cs


注:本文中的ISearchContext.FindElements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。