当前位置: 首页>>代码示例>>C#>>正文


C# By类代码示例

本文整理汇总了C#中By的典型用法代码示例。如果您正苦于以下问题:C# By类的具体用法?C# By怎么用?C# By使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


By类属于命名空间,在下文中一共展示了By类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的By类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。