本文整理汇总了C#中IWebElement.FindElements方法的典型用法代码示例。如果您正苦于以下问题:C# IWebElement.FindElements方法的具体用法?C# IWebElement.FindElements怎么用?C# IWebElement.FindElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWebElement
的用法示例。
在下文中一共展示了IWebElement.FindElements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFancySelectOptions
public static KeyValuePair<string, IWebElement>[] GetFancySelectOptions(IWebElement fancyElement)
{
return fancyElement
.FindElements(By.CssSelector("li > a"))
.Select(x => new KeyValuePair<string, IWebElement>(x.GetAttribute("text"), x))
.ToArray();
}
示例2: GetSelectOptions
public static KeyValuePair<string, string>[] GetSelectOptions(IWebElement selectElement)
{
var options = selectElement.FindElements(By.TagName("option"));
return options
.Select(x => new KeyValuePair<string, string>(x.GetAttribute("value"), x.GetAttribute("text")))
.ToArray();
}
示例3: GetDomainName
protected override string GetDomainName(IWebElement el)
{
var result = string.Empty;
Driver.RepeatFindAndExecuteAction
(
() =>
{
var row = el.FindElements(DomainNameElementLocator).FirstOrDefault(x => x.IsDisplayed());
return row.FindElements(By.CssSelector("span")).FirstOrDefault(x=> x.IsDisplayed() && !String.IsNullOrWhiteSpace(x.GetAttribute("email")));
},
x =>
{
var address = new MailAddress(x.GetAttribute(DomainNameAttributeName));
result = address.Host;
},
() => Delay(),
WebDriverDefaults.NumberOfRetriesForStaleExceptions
);
return result;
}
示例4: Table
protected List<IWebElement> _tableRows; //List of all the rows to loop through to look for matches.
#endregion Fields
#region Constructors
public Table(IWebElement table)
{
try
{
//Look for and assign the tbody element
_tableBody = table.FindElement(By.TagName("tbody"));
}
catch (Exception ex)
{
throw new Exception(string.Format("Couldn't find a tbody tag for this table. {0}", ex.Message));
}
try
{
//Look for all the table headers
_tableHeaders = table.FindElements(By.TagName("th")).ToList();
}
catch (Exception ex)
{
throw new Exception(string.Format("Couldn't find any th tags within this table. {0}", ex.Message));
}
try
{
//Look for all the table rows
_tableRows = _tableBody.FindElements(By.TagName("tr")).ToList();
}
catch (Exception ex)
{
throw new Exception(string.Format("This table doesn't contain any rows. {0}", ex.Message));
}
}
示例5: WaitForAutocomplete
public void WaitForAutocomplete(IWebElement el)
{
new WebDriverWait(driver, TimeSpan.FromSeconds(explTimeout)).Until<Boolean>(drv =>
{
return (el.Displayed && el.FindElements(By.CssSelector("li")).Count > 0);
});
}
示例6: ColumnCount
public int ColumnCount(IWebElement element)
{
IList<IWebElement> tableRows = element.FindElements(By.CssSelector("tr"));
IWebElement headerRow = tableRows[0];
IList<IWebElement> tableCols = headerRow.FindElements(By.CssSelector("td"));
return tableCols.Count();
}
示例7: FindElementsWithTimeoutWait
/// <summary>
/// Finds the elements with timeout wait.
/// </summary>
/// <param name="currentElement">The current element.</param>
/// <param name="by">The by.</param>
/// <returns></returns>
public static ReadOnlyCollection<IWebElement> FindElementsWithTimeoutWait(IWebElement currentElement, By by)
{
Exception ex = null;
ReadOnlyCollection<IWebElement> e = null;
long elapsedTime = 0;
while (elapsedTime < TimeOut)
{
try
{
elapsedTime++;
StandardSleep(1);
e = currentElement.FindElements(by);
break;
}
catch (NoSuchElementException nse)
{
if (e == null)
throw ex;
}
}
if (e == null)
throw ex;
return e;
}
示例8: IsGoogleMapDisplayed
private bool IsGoogleMapDisplayed(IWebElement containerElement)
{
var mapElements = containerElement
.FindElements(By.CssSelector("div.gm-style"))
.Where(x => x.Displayed);
return mapElements.Count() > 0;
}
示例9: FunctionsTableRow
internal FunctionsTableRow(IWebElement rowElement)
: base(rowElement, isHeaderRow: false)
{
if (!string.Equals(rowElement.GetAttribute("ng-repeat"), "entry in functionDefinitions.page") ||
rowElement.FindElements(By.TagName(Tags.Td)).Count != 2)
{
throw new ArgumentException("The element is not a functions table data row", "rowElement");
}
}
示例10: GetGridHeaders
private static IEnumerable<IWebElement> GetGridHeaders(IWebElement element, ByEx columnHeader)
{
var columnElements = element.FindElements(columnHeader);
if (columnElements.ToList().Count == 0)
{
throw new InvalidCastException("WebElement is not a valid TableElement, no th or td tags in first tr.");
}
return columnElements;
}
示例11: FunctionArgumentsTableRow
internal FunctionArgumentsTableRow(IWebElement rowElement)
: base(rowElement, isHeaderRow: false)
{
if (!string.Equals(rowElement.GetAttribute("ng-repeat"), "param in model.parameters") ||
rowElement.FindElements(By.TagName(Tags.Td)).Count != 3)
{
throw new ArgumentException("The element is not a function arguments table row", "rowElement");
}
}
示例12: clearStarsField
public void clearStarsField(IWebElement webElement)
{
ReadOnlyCollection<IWebElement> elements = webElement.FindElements(By.XPath(".//div[contains(@class,'b-control-ratings-star')]"));
if (getStarsField(webElement) != 1)
{
elements[0].Click();
}
elements[0].Click();
}
示例13: GetElements
private static IWebElement GetElements(IWebElement driver, string query, int index)
{
var elements = driver.FindElements(By.XPath(query));
if (!elements.Any())
{
throw new Exception(string.Format("No elements returned with query {0} looking for index {1}", query, index));
}
return elements[index];
}
示例14: TransformWebListToCSharpList
public static List<jcElementWrapper> TransformWebListToCSharpList(IWebElement theList)
{
var returnList = new List<jcElementWrapper>();
var elements = theList.FindElements(By.CssSelector("li"));
foreach (var el in elements)
{
returnList.Add(new jcElementWrapper(el));
}
return returnList;
}
示例15: HeadingsDownSideTable
public HeadingsDownSideTable(IWebElement table)
{
var trs = table.FindElements(By.TagName("tr"));
Assert.That(trs.Any(), "Table seems to be empty. " + table.Text);
this.Rows = trs.Select(row => new Row
{
Heading = row.FindElement(By.TagName("th")),
Cells = row.FindElements(By.TagName("td")).ToList()
}).ToList();
}