本文整理汇总了C#中IWebElement.GetAll方法的典型用法代码示例。如果您正苦于以下问题:C# IWebElement.GetAll方法的具体用法?C# IWebElement.GetAll怎么用?C# IWebElement.GetAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWebElement
的用法示例。
在下文中一共展示了IWebElement.GetAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Find
public ComponentScopeLocateResult Find(IWebElement scope, ComponentScopeLocateOptions options, SearchOptions searchOptions)
{
By by = By.CssSelector(string.Join(",", options.Terms));
if (options.Index.HasValue)
{
var elements = scope.GetAll(by.With(searchOptions));
if (elements.Count <= options.Index.Value)
throw ExceptionFactory.CreateForNoSuchElement(by: by, searchContext: scope);
else
return new SequalComponentScopeLocateResult(elements[options.Index.Value], sequalStrategy);
}
else
{
return new SequalComponentScopeLocateResult(by, sequalStrategy);
}
}
示例2: Find
public ComponentScopeLocateResult Find(IWebElement scope, ComponentScopeLocateOptions options, SearchOptions searchOptions)
{
var headers = scope.GetAll(By.XPath(headerXPath).OfAnyVisibility());
var headerNamePredicate = options.Match.GetPredicate();
int? columnIndex = headers.
Select((x, i) => new { Text = x.Text, Index = i }).
Where(x => options.Terms.Any(term => headerNamePredicate(x.Text, term))).
Select(x => (int?)x.Index).
FirstOrDefault();
if (columnIndex == null)
{
if (searchOptions.IsSafely)
return new MissingComponentScopeLocateResult();
else
throw ExceptionFactory.CreateForNoSuchElement(options.GetTermsAsString(), searchContext: scope);
}
return new FindByColumnIndexStrategy(columnIndex.Value).Find(scope, options, searchOptions);
}
示例3: ResolveScopeLocateResults
private XPathComponentScopeLocateResult[] ResolveScopeLocateResults(ComponentScopeLocateResult result, IWebElement scopeSource, SearchOptions searchOptions)
{
result.CheckNotNull("result");
MissingComponentScopeLocateResult missingResult = result as MissingComponentScopeLocateResult;
if (missingResult != null)
return null;
XPathComponentScopeLocateResult xPathResult = result as XPathComponentScopeLocateResult;
if (xPathResult != null)
return new[] { xPathResult };
SequalComponentScopeLocateResult sequalResult = result as SequalComponentScopeLocateResult;
if (sequalResult != null)
{
ComponentScopeLocateOptions nextScopeLocateOptions = sequalResult.ScopeLocateOptions ?? scopeLocateOptions;
if (sequalResult.ScopeSource != null)
{
ComponentScopeLocateResult nextResult = sequalResult.Strategy.Find(sequalResult.ScopeSource, nextScopeLocateOptions, searchOptions);
return ResolveScopeLocateResults(nextResult, sequalResult.ScopeSource, searchOptions);
}
else
{
IWebElement[] nextScopeSources = scopeSource.GetAll(sequalResult.ScopeSourceBy.With(searchOptions)).ToArray();
SearchOptions nextSearchOptions = SearchOptions.SafelyAndImmediately();
var results = nextScopeSources.
Select(nextScopeSource => sequalResult.Strategy.Find(nextScopeSource, nextScopeLocateOptions, nextSearchOptions)).
Select(nextResult => ResolveScopeLocateResults(nextResult, nextScopeSources[0], nextSearchOptions)).
Where(xPathResults => xPathResults != null).
SelectMany(xPathResults => xPathResults).
ToArray();
if (results.Any())
return results;
else if (searchOptions.IsSafely)
return null;
else
throw ExceptionFactory.CreateForNoSuchElement(by: sequalResult.ScopeSourceBy);
}
}
throw new ArgumentException("Unsupported ComponentScopeLocateResult type: {0}".FormatWith(result.GetType().FullName), "result");
}