本文整理汇总了C#中IWebElement.FindElement方法的典型用法代码示例。如果您正苦于以下问题:C# IWebElement.FindElement方法的具体用法?C# IWebElement.FindElement怎么用?C# IWebElement.FindElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWebElement
的用法示例。
在下文中一共展示了IWebElement.FindElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Link4VehicleVariant
public Link4VehicleVariant(IWebElement variant)
{
_version = variant.FindElement(By.XPath("div/div[1]/span/label")).Text;
_volume = variant.FindElement(By.XPath("div/div[2]")).Text;
_power = variant.FindElement(By.XPath("div/div[3]")).Text;
_body = variant.FindElement(By.XPath("div/div[4]")).Text;
}
示例2: ParseSpecDetail
static SpecDetail ParseSpecDetail(IWebElement specDetail)
{
return new SpecDetail
{
Id = specDetail.FindElement(By.CssSelector("a.description")).GetAttribute("href"),
Message = specDetail.FindElement(By.CssSelector(".resultMessage")).Text,
};
}
示例3: FindElement
public static IWebElement FindElement(this IWebDriver driver, By @by, IWebElement parent, int timeoutInSeconds)
{
if (timeoutInSeconds > 0)
{
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));
return wait.Until(drv => parent.FindElement(by));
}
return parent.FindElement(by);
}
示例4: GetTestResultFromTestOutPut
private static ITestResult GetTestResultFromTestOutPut(IWebElement testOutput)
{
var testResult = new TestResult();
var classAttribute = testOutput.GetAttribute("class");
var moduleName = testOutput.FindElement(By.ClassName("module-name")).Text.Trim();
var testName = testOutput.FindElement(By.ClassName("test-name")).Text.Trim();
var testMessages = GetAggregatedQunitAssertMessages(testOutput);
testResult.Result = classAttribute.Equals("pass") ? UnitTestResult.Passed : UnitTestResult.Failed;
testResult.Message = testMessages;
testResult.TestName = string.Format("{0} : {1}", moduleName, testName);
return testResult;
}
示例5: SetDesiredTemp
internal void SetDesiredTemp(IWebElement thermostatRow, double temp)
{
var xPath = XPath.ThermostatDesiredTempInput();
var inputField = thermostatRow.FindElement(xPath);
inputField.Clear();
inputField.SendKeys(temp.ToString());
}
示例6: GetTableBody
private static IEnumerable<Row> GetTableBody(IWebElement tableElement)
{
var bodyElement = tableElement.FindElement(By.TagName("tbody"));
var bodyRows = bodyElement.FindElements(By.TagName("tr"));
var rows = new List<Row>();
for (int rowIndex = 0; rowIndex < bodyRows.Count; rowIndex++)
{
var bodyRow = bodyRows[rowIndex];
var cells = bodyRow.FindElements(By.TagName("td"));
var row = new Row { Index = rowIndex };
for (int columnIndex = 0; columnIndex < cells.Count; columnIndex++)
{
var cell = cells[columnIndex];
row.Cells.Add(new Cell { ColumnId = columnIndex, Value = cell.Text, WebElement = cell });
}
rows.Add(row);
}
return rows;
}
示例7: OpenInNewTab
public static void OpenInNewTab(IWebElement item)
{
var url = item.FindElement(By.TagName("a"));
url.SendKeys(Keys.Control + Keys.Return);
url.SendKeys(Keys.Control + Keys.Tab);
Cons.driver.SwitchTo().Window(Cons.driver.WindowHandles[Cons.driver.WindowHandles.Count - 1]);
}
示例8: 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));
}
}
示例9: extractListing
private Listing extractListing(IWebElement iWebElement)
{
var listing = new Listing();
try
{
//listing.Publish = iWebElement.FindElement(By.CssSelector("span time")).Text;
//listing.Title = iWebElement.FindElement(By.CssSelector("span a")).Text;
listing.Price = iWebElement.FindElement(PriceBy).Text.Replace("$", "").Replace(",", "");
//string raw = iWebElement.FindElement(By.CssSelector("span span.housing"))
// .Text.Replace('/', ' ')
// .Replace(" ", "");
//listing.Bed = raw.Split('-')[0].Replace("br", "");
var sqft = iWebElement.FindElement(SqFtBy).Text.Replace(",", "").Trim();
if (string.IsNullOrEmpty(sqft))
sqft = "0";
listing.Sqft = sqft;
listing.Address = iWebElement.FindElement(Address).GetAttribute("title").Replace(",", "");
return listing;
}
catch (Exception)
{
return listing;
}
}
示例10: ParseTestResult
TestResult ParseTestResult(IWebElement testOutput)
{
var testName = testOutput.FindElement(By.ClassName("test-name")).Text;
var resultClass = testOutput.GetAttribute("class");
if (resultClass == "pass")
return CreateTestResult(testName, true, string.Empty);
if (resultClass == "fail")
return CreateTestResult(testName, false, testOutput.FindElement(By.ClassName("fail")).Text);
if (resultClass == "running")
return CreateTestResult(testName, false, "The test did not finish within time limit.");
return CreateTestResult(testName, false, "Unknown test class: '" + resultClass + "'");
}
示例11: LocateAssertMessage
public string LocateAssertMessage(IWebElement fromElement) {
try {
return fromElement.FindElement(By.ClassName("test-message")).Text;
}
catch(NoSuchElementException) {
return "";
}
}
示例12: LocateAssertSource
public string LocateAssertSource(IWebElement fromElement) {
try {
return fromElement.FindElement(By.CssSelector(".test-source pre")).Text;
}
catch(NoSuchElementException) {
return "";
}
}
示例13: SelectComboBox
public static void SelectComboBox(IWebElement element, string id, int numDown)
{
IWebElement selectBox = element.FindElement(By.Id(id));
for (int i = 0; i > numDown; i++)
{
selectBox.SendKeys(Keys.Down);
}
}
示例14: ExpandMenu
private static IWebElement ExpandMenu(IWebElement block, IWebElement menu)
{
if (!IsExpanded(block))
{
block.FindElement(By.CssSelector("[class*='ui-selectmenu-button']")).FindElement(By.CssSelector("[class*='ui-icon']")).Click();
}
return menu.FindElement(By.CssSelector("[class*='ui-selectmenu-menu'][class*='selectmenu-open']"));
}
示例15: GetTableHeaders
private static IEnumerable<Column> GetTableHeaders(IWebElement tableElement)
{
var headElement = tableElement.FindElement(By.TagName("thead"));
var headRow = headElement.FindElement(By.TagName("tr"));
var headCells = headRow.FindElements(By.TagName("th"));
return headCells.Select((headCell, index) => new Column { Id = index, Index = index, Name = headCell.Text });
}