本文整理汇总了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;
}
示例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;
}
}
}
}
示例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();
}
示例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());
}
示例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;
}
示例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();
}
示例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();
}
示例8:
IReadOnlyCollection<IWebElement> IFind.Find(ISearchContext context, string searchText)
{
return context.FindElements(ByJQuery.CssSelector(searchText));
}
示例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();
}
示例10: WhereAHeaderMatches
private bool WhereAHeaderMatches(ISearchContext e, string locator)
{
return e.FindElements(By.XPath("./*")).Any(h => headerTags.Contains(h.TagName) && textMatcher.TextMatches(h, locator));
}
示例11:
IReadOnlyCollection<IWebElement> IFind.Find(ISearchContext context, string searchText)
{
return context.FindElements(By.XPath(".//*[text() = " + Utility.XPathString(searchText) + "]"));
}
示例12:
IReadOnlyCollection<IWebElement> IFind.Find(ISearchContext context, string searchText)
{
return context.FindElements(By.XPath(searchText));
}
示例13: GetDropDownListContent
private static List<string> GetDropDownListContent(ISearchContext selectDocumentTypeDropDown)
{
return selectDocumentTypeDropDown.FindElements(By.TagName("option")).Select(option => option.Text).ToList();
}
示例14:
IReadOnlyCollection<IWebElement> IFind.Find(ISearchContext context, string searchText)
{
return context.FindElements(By.CssSelector("*[value=" + Utility.CssString(searchText) + "]"));
}