本文整理汇总了C#中IWebElement类的典型用法代码示例。如果您正苦于以下问题:C# IWebElement类的具体用法?C# IWebElement怎么用?C# IWebElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IWebElement类属于命名空间,在下文中一共展示了IWebElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetElementLocation
public static Point GetElementLocation(IWebElement element)
{
Point location = GetElementOrigin(element);
Size size = GetElementSize(element);
return new Point(location.X + size.Width / 2, location.Y + size.Height / 2);
}
示例2: UntilVisible
public static IWebElement UntilVisible(IWebElement element, TimeSpan timeOut)
{
Stopwatch sw = new Stopwatch();
sw.Start();
while (true)
{
WebDriverException lastException = null;
try
{
if (element.Displayed)
{
return element;
}
System.Threading.Thread.Sleep(100);
}
catch (ElementNotVisibleException e) { lastException = e; }
catch (NoSuchElementException e) { lastException = e; }
catch (StaleElementReferenceException e) { lastException = e; }
if (sw.Elapsed > timeOut)
{
string exceptionMessage = lastException == null ? "" : lastException.Message;
string errorMessage = string.Format("Wait.UntilVisible: Element was not displayed after {0} Milliseconds" +
"\r\n Error Message:\r\n{1}", timeOut.TotalMilliseconds, exceptionMessage);
throw new TimeoutException(errorMessage);
}
}
}
示例3: generateSequence
private void generateSequence(
TranscriptCmdletBase cmdlet,
System.Collections.Generic.List<IRecordedCodeSequence> recordingsCollection,
IRecordedCodeSequence codeSequence,
IWebElement firstElement,
IWebElement secondElement)
{
Recorder.RecordingCollection = recordingsCollection;
codeSequence =
Recorder.RecordCodeSequence(
cmdlet,
Recorder.RecordingCollection,
firstElement,
codeSequence);
if (null != secondElement) {
codeSequence =
Recorder.RecordCodeSequence(
cmdlet,
Recorder.RecordingCollection,
secondElement,
codeSequence);
}
Recorder.StoreCodeSequenceInCollection(
cmdlet,
Recorder.RecordingCollection,
codeSequence);
}
示例4: EnterData
public void EnterData(ISearchContext context, IWebElement element, object data)
{
var options = findOptions(element);
foreach (var option in options)
{
if (option.Text == data.ToString())
{
option.Click();
return;
}
}
foreach (var option in options)
{
if (option.GetAttribute("value") == data.ToString())
{
option.Click();
return;
}
}
var message = "Cannot find the desired option\nThe available options are\nDisplay/Key\n";
foreach (var option in options)
{
message += "\n" + "{0}/{1}".ToFormat(option.Text, option.GetAttribute("value"));
}
StoryTellerAssert.Fail(message);
}
示例5: BaseEmailEngager
protected BaseEmailEngager(Context context, IWebElement listItem) : base(context)
{
ListItem = listItem;
DomainName = GetDomainName(listItem);
CurrentDomain = context.GetDomain(DomainName);
context.CurrentDomain = CurrentDomain;
}
示例6: FakeWebElement
/// <summary>
/// Like decorator
/// </summary>
/// <param name="realWebElement"></param>
public FakeWebElement(IWebElement realWebElement)
//public WebElementDecorator(RemoteWebElement realWebElement) // : base(realWebElement.WrappedDriver, "")
{
this.DecoratedWebElement = realWebElement as FakeWebElement;
this.SearchHistory =
new List<ISearchHistory>();
}
示例7: Execute
protected override void Execute(IWebDriver driver, dynamic context, IWebElement element)
{
if (IsFalseExpected)
Assert.False(element.Enabled);
else
Assert.True(element.Enabled);
}
示例8: Execute
protected override void Execute(IWebDriver driver, IWebElement element, CommandDesc command)
{
if (element.Selected)
{
element.Click();
}
}
示例9: 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();
}
示例10: Find
public ComponentScopeLocateResult Find(IWebElement scope, ComponentScopeLocateOptions options, SearchOptions searchOptions)
{
string labelXPath = new ComponentScopeXPathBuilder(options).
WrapWithIndex(x => x.Descendant._("label")[y => y.TermsConditionOfContent]);
IWebElement label = scope.Get(By.XPath(labelXPath).With(searchOptions).Label(options.GetTermsAsString()));
if (label == null)
{
if (searchOptions.IsSafely)
return new MissingComponentScopeLocateResult();
else
throw ExceptionFactory.CreateForNoSuchElement(options.GetTermsAsString(), searchContext: scope);
}
string elementId = label.GetAttribute("for");
if (string.IsNullOrEmpty(elementId))
{
return new SequalComponentScopeLocateResult(label, new FindFirstDescendantStrategy());
}
else
{
ComponentScopeLocateOptions idOptions = options.Clone();
idOptions.Terms = new[] { elementId };
idOptions.Index = null;
idOptions.Match = TermMatch.Equals;
return new SequalComponentScopeLocateResult(scope, new FindByIdStrategy(), idOptions);
}
}
示例11: 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);
});
}
示例12: AssertElementsPresent
public static void AssertElementsPresent(IWebElement[] elements, string elementDescription)
{
if (elements.Length == 0)
{
throw new AssertionException(String.Format("AssertElementsPresent Failed: Could not find '{0}'", elementDescription));
}
}
示例13: AssertElementPresent
public static void AssertElementPresent(IWebElement element, string elementDescription)
{
if (!IsElementPresent(element))
{
throw new AssertionException(String.Format("AssertElementPresent Failed: Could not find '{0}'", elementDescription));
}
}
示例14: 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;
}
示例15: Check
public static void Check(IWebElement checkbox)
{
if (!IsChecked(checkbox))
{
checkbox.Click();
}
}