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


C# ISearchContext.FindElement方法代码示例

本文整理汇总了C#中ISearchContext.FindElement方法的典型用法代码示例。如果您正苦于以下问题:C# ISearchContext.FindElement方法的具体用法?C# ISearchContext.FindElement怎么用?C# ISearchContext.FindElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISearchContext的用法示例。


在下文中一共展示了ISearchContext.FindElement方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindTextbox

        public static IWebElement FindTextbox(ISearchContext context, IWebElement element)
        {
            var id = element.GetAttribute("id");
            var labelId = id + "Value";

            return context.FindElement(By.Id(labelId));
        }
开发者ID:DarthFubuMVC,项目名称:FubuMVC.AutoComplete,代码行数:7,代码来源:AutoCompleteHandler.cs

示例2: LocateElement

        /// <summary>
        /// Locates an element using the given <see cref="ISearchContext"/> and list of <see cref="By"/> criteria.
        /// </summary>
        /// <param name="searchContext">The <see cref="ISearchContext"/> object within which to search for an element.</param>
        /// <param name="bys">The list of methods by which to search for the element.</param>
        /// <returns>An <see cref="IWebElement"/> which is the first match under the desired criteria.</returns>
        public IWebElement LocateElement(ISearchContext searchContext, IEnumerable<By> bys)
        {
            if (searchContext == null)
            {
                throw new ArgumentNullException("searchContext", "searchContext may not be null");
            }

            if (bys == null)
            {
                throw new ArgumentNullException("bys", "List of criteria may not be null");
            }

            string errorString = null;
            foreach (var by in bys)
            {
                try
                {
                    return searchContext.FindElement(by);
                }
                catch (NoSuchElementException)
                {
                    errorString = (errorString == null ? "Could not find element by: " : errorString + ", or: ") + by;
                }
            }

            throw new NoSuchElementException(errorString);
        }
开发者ID:BogdanLivadariu,项目名称:selenium,代码行数:33,代码来源:DefaultElementLocatorFactory.cs

示例3: IsElementPresent

 public static bool IsElementPresent(ISearchContext context, By searchBy)
 {
     try {
         var b = context.FindElement(searchBy).Displayed;
         return true;
     }
     catch {
         return false;
     }
 }
开发者ID:divyang4481,项目名称:appleseedapp,代码行数:10,代码来源:CommonBase.cs

示例4: GetText

 private string GetText(By xpath, ISearchContext seleniumScope)
 {
     var pageText = seleniumScope.FindElement(xpath).Text;
     return NormalizeCRLFBetweenBrowserImplementations(pageText);
 }
开发者ID:rbhattarai,项目名称:DWSelFramework,代码行数:5,代码来源:SeleniumWebDriver.cs

示例5: LocateElement

        /// <summary>
        /// Locates an element using the given <see cref="ISearchContext"/> and list of <see cref="By"/> criteria.
        /// </summary>
        /// <param name="searchContext">The <see cref="ISearchContext"/> object within which to search for an element.</param>
        /// <param name="bys">The list of methods by which to search for the element.</param>
        /// <returns>An <see cref="IWebElement"/> which is the first match under the desired criteria.</returns>
        public IWebElement LocateElement(ISearchContext searchContext, IEnumerable<By> bys)
        {
            if (searchContext == null)
            {
                throw new ArgumentNullException("searchContext", "searchContext may not be null");
            }

            if (bys == null)
            {
                throw new ArgumentNullException("bys", "List of criteria may not be null");
            }

            string errorString = null;
            DateTime endTime = DateTime.Now.Add(this.timeout);
            bool timeoutReached = DateTime.Now > endTime;
            while (!timeoutReached)
            {
                foreach (var by in bys)
                {
                    try
                    {
                        return searchContext.FindElement(by);
                    }
                    catch (NoSuchElementException)
                    {
                        errorString = (errorString == null ? "Could not find element by: " : errorString + ", or: ") + by;
                    }
                }

                timeoutReached = DateTime.Now > endTime;
                if (!timeoutReached)
                {
                    Thread.Sleep(this.pollingInterval);
                }
            }

            throw new NoSuchElementException(errorString);
        }
开发者ID:JacquesBonet,项目名称:selenium-1,代码行数:44,代码来源:RetryingElementLocatorFactory.cs

示例6: VerifyRowMatched

 private bool VerifyRowMatched(ISearchContext webElement)
 {
     var values = Data.Split('|');
     return values.Select(value => webElement.FindElement(By.XPath("//*[contains(text(),'" + value + "')]"))).All(td => td != null);
 }
开发者ID:bperreault,项目名称:autox,代码行数:5,代码来源:VerifyTable.cs

示例7: ForElement

   public static IWebElement ForElement(ISearchContext searchContext,
 By by, int millisecondsToWait = DefaultTimeout)
   {
       var endTime = DateTime.Now.AddMilliseconds(millisecondsToWait);
       while (DateTime.Now < endTime)
       {
           try
           {
               var element = searchContext.FindElement(by);
               return element;
           }
           catch (NoSuchElementException) { }
       }
       throw new NoSuchElementException(by + " not found in " +
   millisecondsToWait + "ms");
   }
开发者ID:ryanmalone,项目名称:BGDNNWEB,代码行数:16,代码来源:Base.cs

示例8: WaitForElement

 protected IWebElement WaitForElement(ISearchContext context, By selector)
 {
     return Wait.For(() => context.FindElement(selector));
 }
开发者ID:chriscore,项目名称:SpecDriver,代码行数:4,代码来源:BasePage.cs

示例9: FindElement

        public static IWebElement FindElement(ISearchContext context, By searchBy, string elementDescription)
        {
            IWebElement element = null;
            try
            {
                element = context.FindElement(searchBy);
            }
            catch (NoSuchElementException e)
            {
                e.ToString();

                if (!IsElementPresent(context, searchBy))
                    throw new AssertionException(string.Format("AssertElementPresent Failed: Could not find '{0}'",
                        elementDescription));
            }
            return element;
        }
开发者ID:rohanbaraskar,项目名称:SeleniumAutomationFramework,代码行数:17,代码来源:CommonBase.cs

示例10: IsElementPresent

        // NOTE: Again as above, this method checks if an element is Displayed as opposed to being present
        //       Although there is a try and catch and the catch will work just fine if an element is not present.
        public static bool IsElementPresent(ISearchContext context, By searchBy, int maxDuration)
        {
            var retryInterval = 1000; // 1 sec
            var maxDuration2 = maxDuration;
            var isPresent = false;

            while (maxDuration2 > 0)
            {
                try
                {
                    var b = context.FindElement(searchBy).Displayed;
                    isPresent = true;
                    break;
                }
                catch (Exception ex)
                {
                    Trace.Write(ex.Message);
                }

                Thread.Sleep(retryInterval);
                maxDuration2 -= retryInterval;
            }
            return isPresent;
        }
开发者ID:rohanbaraskar,项目名称:SeleniumAutomationFramework,代码行数:26,代码来源:CommonBase.cs


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