本文整理汇总了C#中By类的典型用法代码示例。如果您正苦于以下问题:C# By类的具体用法?C# By怎么用?C# By使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
By类属于命名空间,在下文中一共展示了By类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestSearchContext
public TestSearchContext(TestSettings settings, By selfSelector, ISearchContext context,Func<IWebElement> selfLookup)
{
_settings = settings;
_selfSelector = selfSelector;
_context = context;
_selfLookup = selfLookup;
}
开发者ID:Jayman1305,项目名称:Selenium.Extensions,代码行数:7,代码来源:TestSearchContext.cs
示例2: FindElements
public ReadOnlyCollection<IWebElement> FindElements(By @by)
{
var element = _context as IWebElement;
return new EagerReadOnlyCollection<IWebElement>(() =>
(element != null
? TestInteractionWrapper.Interact(ref element, _selfSelector, () => _selfLookup(),
lmnt => _selfLookup().FindElements(@by))
: _context.FindElements(@by))
.Select((lmnt, index) =>
{
//each element must be able to re-resolve it self
//in this case, re-resolve all elements again and just pick the
//element that has the same index as before
return new TestWebElement(_settings, lmnt, @by, this,
ctx =>
{
var children = _selfLookup == null
? _context.FindElements(@by)
: _selfLookup().FindElements(@by);
return children.ElementAt(index);
});
})
);
}
开发者ID:Jayman1305,项目名称:Selenium.Extensions,代码行数:26,代码来源:TestSearchContext.cs
示例3: Lookup
/// <summary>
/// Lookup a reference field value.
/// </summary>
/// <param name="driver"></param>
/// <param name="by">A mechanism by which to find the desired reference field within the current document.</param>
/// <param name="sendKeys">A property value of the current reference field.</param>
public static void Lookup(this IWebDriver driver, By by, string sendKeys)
{
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
IWebElement lookup = wait.Until(ExpectedConditions.ElementIsVisible(by));
lookup.Click();
string currentWindowHandle = driver.CurrentWindowHandle;
string searchWindow = driver.WindowHandles.First(o => o != currentWindowHandle);
driver.SwitchTo().Window(searchWindow);
IWebElement searchFor = wait.Until(ExpectedConditions.ElementExists(By.ClassName("list_search_text")));
searchFor.Click();
searchFor.Clear();
searchFor.SendKeys(sendKeys);
var selects = driver.FindElements(By.ClassName("list_search_select"));
IWebElement search = selects.First(o => o.GetAttribute("id").Contains("_select"));
driver.SelectOption(search, "Name"); //"for text");
wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("img[title='Go']"))).Click();
IWebElement item = wait.Until(ExpectedConditions.ElementExists(By.LinkText(sendKeys)));
item.Click();
driver.SwitchTo().Window(currentWindowHandle);
driver.SwitchTo().Frame("gsft_main");
}
开发者ID:rburkitt,项目名称:ServiceNowWebDriverExtensions,代码行数:35,代码来源:WebDriverExtensions.cs
示例4: PolicyResultCacheStrategy
public PolicyResultCacheStrategy(string controllerName, string actionName, Type policyType, Cache cacheLifecycle, By cacheLevel = By.ControllerAction)
{
ControllerName = controllerName;
ActionName = actionName;
PolicyType = policyType;
CacheLifecycle = cacheLifecycle;
CacheLevel = cacheLevel;
}
开发者ID:protechdm,项目名称:CloudCompare,代码行数:8,代码来源:PolicyResultCacheStrategy.cs
示例5: ElementPresent
/// <summary>
/// Waits for the element to be present present with a optional time.
/// </summary>
/// <param name="browser">The browser.</param>
/// <param name="locator">The locator.</param>
/// <param name="timeSpan">The time span.</param>
public static void ElementPresent(IWebDriver browser, By locator, TimeSpan? timeSpan = null)
{
if (timeSpan == null)
{
timeSpan = TimeSpan.FromSeconds(10);
}
WaitForElement(browser, locator, (TimeSpan) timeSpan);
}
开发者ID:Jayman1305,项目名称:Selenium.Extensions,代码行数:14,代码来源:WaitUntil.cs
示例6: FindElements
public static ReadOnlyCollection<IWebElement> FindElements(this IWebDriver driver, By by, int timeoutInSeconds)
{
if (timeoutInSeconds > 0)
{
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));
return wait.Until(drv => (drv.FindElements(by).Count > 0) ? drv.FindElements(by) : null);
}
return driver.FindElements(by);
}
开发者ID:athlete1,项目名称:UXTestingFrameworks,代码行数:9,代码来源:WebDriverExtensions.cs
示例7: FindElement
public static IWebElement FindElement(this IWebDriver driver, By by, int timeoutInSeconds)
{
if (timeoutInSeconds > 0)
{
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));
return wait.Until(drv => drv.FindElement(by));
}
return driver.FindElement(by);
}
开发者ID:athlete1,项目名称:UXTestingFrameworks,代码行数:9,代码来源:WebDriverExtensions.cs
示例8: ByIdOrName
/// <summary>
/// Initializes a new instance of the <see cref="ByIdOrName"/> class.
/// </summary>
/// <param name="elementIdentifier">The ID or Name to use in finding the element.</param>
public ByIdOrName(string elementIdentifier)
{
if (string.IsNullOrEmpty(elementIdentifier))
{
throw new ArgumentException("element identifier cannot be null or the empty string", "elementIdentifier");
}
this.elementIdentifier = elementIdentifier;
this.idFinder = By.Id(this.elementIdentifier);
this.nameFinder = By.Name(this.elementIdentifier);
}
开发者ID:JacquesBonet,项目名称:selenium-1,代码行数:15,代码来源:ByIdOrName.cs
示例9: Find
public RankedPair Find(By findBy)
{
if (persons.Count < 2)
return new RankedPair();
var pairListing = (from person in persons
from person1 in persons.Skip(persons.IndexOf(person) + 1)
select person.BirthDate < person1.BirthDate ? new RankedPair(person, person1) : new RankedPair(person1, person)).OrderBy(x => x.AgeGap);
return findBy == By.Closest ? pairListing.First() : pairListing.Last();
}
开发者ID:bforrest,项目名称:Katas,代码行数:11,代码来源:Finder.cs
示例10: IsElementPresent
private bool IsElementPresent(By by)
{
try
{
driver.FindElement(by);
return true;
}
catch (NoSuchElementException)
{
return false;
}
}
开发者ID:tarikburakozonder,项目名称:sindirella,代码行数:12,代码来源:Hepsi.cs
示例11: HasElement
public static bool HasElement(this IWebDriver driver, By by)
{
try
{
driver.FindElement(by);
}
catch (NoSuchElementException)
{
return false;
}
return true;
}
开发者ID:athlete1,项目名称:UXTestingFrameworks,代码行数:13,代码来源:WebDriverExtensions.cs
示例12: isPresent
public static bool isPresent(this IWebDriver driver, By bylocator)
{
bool variable = false;
try
{
IWebElement element = driver.FindElement(bylocator);
variable = element != null;
}
catch (NoSuchElementException)
{
}
return variable;
}
开发者ID:athlete1,项目名称:UXTestingFrameworks,代码行数:14,代码来源:WebDriverExtensions.cs
示例13: ElementIsVisible
/// <summary>
/// An expectation for checking that an element is present on the DOM of a page
/// and visible. Visibility means that the element is not only displayed but
/// also has a height and width that is greater than 0.
/// </summary>
/// <param name="locator">The locator used to find the element.</param>
/// <returns>The <see cref="IWebElement"/> once it is located and visible.</returns>
public static Func<IWebDriver, IWebElement> ElementIsVisible(By locator)
{
return (driver) =>
{
try
{
return ElementIfVisible(driver.FindElement(locator));
}
catch (StaleElementReferenceException)
{
return null;
}
};
}
开发者ID:kaushik9k,项目名称:Selenium2,代码行数:21,代码来源:ExpectedConditions.cs
示例14: Highlight
public void Highlight(By locator, bool reset)
{
IWebElement element;
try
{
element = _driver.FindElement(locator);
}
catch (Exception)
{
return;
}
HighlightElement(element, reset);
}
开发者ID:Jayman1305,项目名称:Selenium.Extensions,代码行数:14,代码来源:WebDriverHighlighter.cs
示例15: FindElement
public IWebElement FindElement(By @by)
{
var element = _context as IWebElement;
if (element != null)
{
//Console.WriteLine("element->element: {0}", @by);
return TestInteractionWrapper.Interact(
ref element,
_selfSelector,
() => _selfLookup(),
lmnt => new TestWebElement(_settings, lmnt, _selfSelector, this, ctx => ctx.FindElement(@by))
);
}
//context is IWebDriver, no need to guard for stale element
//Console.WriteLine("driver->element: {0}", @by);
element = _context.FindElement(@by);
return new TestWebElement(_settings, element, @by, _context, ctx => ctx.FindElement(@by));
}
开发者ID:Jayman1305,项目名称:Selenium.Extensions,代码行数:19,代码来源:TestSearchContext.cs
示例16: ElementNotVisibleError
internal ElementNotVisibleError(By by)
: base(7, "Element not visible for {0}", by.ToString()) { }
开发者ID:VineGlobal,项目名称:SeleniumBasic,代码行数:2,代码来源:WebRequestErrors.cs
示例17: FindElements
/// <summary>
/// Finds all <see cref="IWebElement">IWebElements</see> within the current context
/// using the given mechanism.
/// </summary>
/// <param name="by">The locating mechanism to use.</param>
/// <returns>A <see cref="ReadOnlyCollection{T}"/> of all <see cref="IWebElement">WebElements</see>
/// matching the current criteria, or an empty list if nothing matches.</returns>
public ReadOnlyCollection<IWebElement> FindElements(By by)
{
if (by == null)
{
throw new ArgumentNullException("by", "by cannot be null");
}
return by.FindElements(this);
}
开发者ID:Goldcap,项目名称:Constellation,代码行数:16,代码来源:RemoteWebElement.cs
示例18: FindElement
/// <summary>
/// Finds the first <see cref="IWebElement"/> using the given method.
/// </summary>
/// <param name="by">The locating mechanism to use.</param>
/// <returns>The first matching <see cref="IWebElement"/> on the current context.</returns>
/// <exception cref="NoSuchElementException">If no element matches the criteria.</exception>
public IWebElement FindElement(By by)
{
if (by == null)
{
throw new ArgumentNullException("by", "by cannot be null");
}
return by.FindElement(this);
}
开发者ID:Goldcap,项目名称:Constellation,代码行数:15,代码来源:RemoteWebElement.cs
示例19: FindElementEventArgs
/// <summary>
/// Initializes a new instance of the <see cref="FindElementEventArgs"/> class.
/// </summary>
/// <param name="driver">The WebDriver instance used in finding elements.</param>
/// <param name="element">The parent element used as the context for the search.</param>
/// <param name="method">The <see cref="By"/> object containing the method used to find elements.</param>
public FindElementEventArgs(IWebDriver driver, IWebElement element, By method)
{
this.driver = driver;
this.element = element;
this.method = method;
}
开发者ID:RanchoLi,项目名称:selenium,代码行数:12,代码来源:FindElementEventArgs.cs
示例20: AutoWatElement
internal AutoWatElement(By finder)
: base(By.Body, null, false)
{
Finder = finder;
}
开发者ID:behaug,项目名称:Venturous,代码行数:5,代码来源:AutoWatElement.cs
注:本文中的By类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论