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


C# Selenium.By类代码示例

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


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

示例1: FindElementsWithTimeoutWait

        /// <summary>
        /// Finds the elements with timeout wait.
        /// </summary>
        /// <param name="driver">The driver.</param>
        /// <param name="by">The by.</param>
        /// <returns></returns>
        public static ReadOnlyCollection<IWebElement> FindElementsWithTimeoutWait(IWebDriver driver, By by)
        {
            Exception ex = null;
            ReadOnlyCollection<IWebElement> e = null;
            long elapsedTime = 0;
            while (elapsedTime < TimeOut)
            {
                try
                {
                    elapsedTime++;
                    StandardSleep(1);
                    e = driver.FindElements(by);
                    break;
                }
                catch (NoSuchElementException nse)
                {
                    if (e == null)
                        throw ex;
                }
            }

            if (e == null)
                throw ex;

            return e;
        }
开发者ID:harindu61,项目名称:twitterTest,代码行数:32,代码来源:ThreadWait.cs

示例2: FindElements

        private IEnumerable<INativeElement> FindElements(By by)
        {
            var elements = _context.FindElements(by);
            foreach (var element in elements)
                yield return new WebDriverNativeElement(element);

        }
开发者ID:exaphaser,项目名称:WatiN,代码行数:7,代码来源:WebDriverNativeElementCollection.cs

示例3: ScrollToAndClick

 public static void ScrollToAndClick(By locator)
 {
     IWebElement element = GenericHelper.GetElement(locator);
     ExecuteScript("window.scrollTo(0," + element.Location.Y + ")");
     Thread.Sleep(300);
     element.Click();
 }
开发者ID:Saltorel,项目名称:BDD-CSharp,代码行数:7,代码来源:JavaScriptExecutor.cs

示例4: ElementIsDisplayed

        public static bool ElementIsDisplayed(this IWebDriver driver, By by)
        {
            System.Threading.Thread.Sleep(5);
            IWebElement el;
            bool isDisplayed = false;
            bool gotBoolean;

            if (driver.ElementExists(by))
            {
                el = driver.FindElement(by);
                do
                {
                    // For whatever reason, on Android this often throws an InvalidCastException
                    try
                    {
                        isDisplayed = el.Displayed;
                        gotBoolean = true;
                    } catch (InvalidCastException)
                    {
                        // Loop until we get either a true or false
                        gotBoolean = false;
                    }
                } while (gotBoolean == false);
                return isDisplayed;
            }
            else
            {
                return false;
            }
        }
开发者ID:jw56578,项目名称:SpecFlowTest,代码行数:30,代码来源:WebDriverExtensions.cs

示例5: Element

        public Element(string element)
        {
            if (string.IsNullOrEmpty(element))
                return;

            // assume XPath expression
            if (element.Contains("/"))
            {
                this.element = By.XPath(element);
                return;
            }

            var token = element.Split('=');
            if (token.Length != 2)
                return;

            var key = token[0].Trim().ToLower();
            var value = token[1].Trim();

            if ("id".Equals(key))
            {
                this.element = By.Id(value);
            }
            else if ("name".Equals(key))
            {
                this.element = By.Name(value);
            }
            else if ("link".Equals(key))
            {
                this.element = By.LinkText(value);
            }
        }
开发者ID:csokun,项目名称:Remo,代码行数:32,代码来源:Element.cs

示例6: GetElements

        public IList<IWebElement> GetElements(By by)
        {
            if (Tag == null)
                throw new NullReferenceException("You can't call GetElements on a block without first initializing Tag.");

            return Tag.FindElements(by);
        }
开发者ID:Hammertime38,项目名称:Bumblebee,代码行数:7,代码来源:Block.cs

示例7: CreateNewPortal

        public static void CreateNewPortal(IWebDriver driver, string portalName, By template)
        {
            Login.AsHost(driver);

            driver.Navigate().GoToUrl(SiteManagementPage);

            driver.WaitClick(CreatePortalButton);

            driver.WaitClick(AddSiteSiteTypeChildRadio);

            driver.FindDnnElement(AddSitePortalAliasTextbox).Clear();

            driver.WaitSendKeys(AddSitePortalAliasTextbox, "localhost/DotNetNuke_Enterprise/" + portalName + "/");

            driver.FindDnnElement(AddSitePortalAliasTextbox).Clear();

            driver.WaitSendKeys(AddSitePortalAliasTextbox, "localhost/DotNetNuke_Enterprise/" + portalName + "/");

            driver.WaitSendKeys(AddSitePortalNameTextbox, portalName);

            driver.WaitClick(AddSiteTemplateInput);
            driver.WaitClick(template);

            driver.WaitClick(AddSiteCreateSiteButton);

            int origTimeout = Common.DriverTimeout;
            Common.DriverTimeout = 30000;
            driver.WaitClick(AddSiteVisitNewPortalLink);
            Common.DriverTimeout = origTimeout;
        }
开发者ID:ryanmalone,项目名称:BGDNNWEB,代码行数:30,代码来源:SiteManagement.cs

示例8: WaitForElementEx

        public static IWebElement WaitForElementEx(this ISearchContext node, By condition, int? maxWaitMS = null, int? waitIntervalMS = null)
        {
            maxWaitMS = maxWaitMS ?? MaxWaitMS;
            waitIntervalMS = waitIntervalMS ?? WaitIntervalMS;

            DateTime finishTime = DateTime.UtcNow.AddMilliseconds(maxWaitMS.Value);

            do
            {
                DateTime timeAttempted = DateTime.UtcNow;
                try
                {
                    return node.FindElement(condition);
                }
                catch (Exception)
                {
                    if (timeAttempted > finishTime)
                    {
                        throw;
                    }
                }

                Thread.Sleep(waitIntervalMS.Value);
            } while (true);
        }
开发者ID:fschwiet,项目名称:SizSelCsZzz,代码行数:25,代码来源:WebDriverExtensions.cs

示例9: WaitUntilElementsInvisible

    public static IEnumerable<IWebElement> WaitUntilElementsInvisible(this IWebDriver driver, By selector)
    {
      var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
      wait.Until(ExpectedConditions.InvisibilityOfElementLocated(selector));

      return driver.FindElements(selector);
    }
开发者ID:alinulms,项目名称:Habitat,代码行数:7,代码来源:SeleniumExtensions.cs

示例10: GetElement

 public static IWebElement GetElement(By locator)
 {
     if (IsElemetPresent(locator))
         return ObjectRepository.Driver.FindElement(locator);
     else
         throw new NoSuchElementException("Element Not Found : " + locator.ToString());
 }
开发者ID:Saltorel,项目名称:BDD-CSharp,代码行数:7,代码来源:GenericHelper.cs

示例11: Element

 /// <summary>
 /// Construct an element
 /// </summary>
 /// <param name="locator">By locator</param>
 public Element(By locator): base()
 {
     this.name = "Element";
     this.by = locator;
     this.pageObjectName = TestBase.GetCurrentClassName();
     this.timeoutSec = Config.Settings.runTimeSettings.ElementTimeoutSec;
 }
开发者ID:tokarthik,项目名称:ProtoTest.Golem,代码行数:11,代码来源:Element.cs

示例12: Element

 /// <summary>
 ///     Construct an element
 /// </summary>
 /// <param name="locator">By locator</param>
 public Element(By locator)
 {
     name = "Element";
     by = locator;
     pageObjectName = TestBase.GetCurrentClassName();
     timeoutSec = Config.Settings.runTimeSettings.ElementTimeoutSec;
 }
开发者ID:sakthijas,项目名称:ProtoTest.Golem,代码行数:11,代码来源:Element.cs

示例13: PageElement

 protected PageElement(By byLocator)
 {
     BaseElement = new CCElement(byLocator);
     if (ValidTags != null && !ValidTags.Contains(BaseElement.TagName.ToLower())) {
         throw new Exception("Tag '" + BaseElement.TagName + "' is not valid");
     }
 }
开发者ID:PortalAutomation,项目名称:Portal-Selenium-Framework,代码行数:7,代码来源:PageElement.cs

示例14: AssertElementPresent

 public static void AssertElementPresent(ISearchContext context, By searchBy, string elementDescription)
 {
     if (!IsElementPresent(context, searchBy))
     {
         throw new AssertionException(String.Format("AssertElementPresent Failed: Could not find '{0}'", elementDescription));
     }
 }
开发者ID:SiteOneSoftware,项目名称:RegistrationFormBddTest,代码行数:7,代码来源:CommonBase.cs

示例15: WaitForElementPresentAndEnabled

 public void WaitForElementPresentAndEnabled(By locator, int secondsToWait = 30)
 {
     new WebDriverWait(this.driver, new TimeSpan(0, 0, secondsToWait))
        .Until(d => d.FindElement(locator).Enabled
            && d.FindElement(locator).Displayed
        );
 }
开发者ID:AndreiSychykau,项目名称:helloci,代码行数:7,代码来源:Page.cs


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