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


C# By.ToString方法代码示例

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


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

示例1: DoNotExist

 public IElementAssert DoNotExist(By findExpression, string message = null, TimeSpan maxWait = default(TimeSpan))
 {
     return DoNotExist(() => Find.Element(findExpression, maxWait), findExpression.ToString(), message);
 }
开发者ID:robdmoore,项目名称:TestStack.Seleno,代码行数:4,代码来源:ElementAssert.cs

示例2: FindElements

 public ReadOnlyCollection<IWebElement> FindElements(By @by)
 {
     if (@by.ToString().Contains("value"))
         return new ReadOnlyCollection<IWebElement>(_childElements);
     if(@by.ToString().Contains("text"))
         return new ReadOnlyCollection<IWebElement>(_childElements);
     return null;
 }
开发者ID:AcklenAvenue,项目名称:Pepino,代码行数:8,代码来源:FakeWebElement.cs

示例3: 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

示例4: WaitForElement

 public void WaitForElement(By by)
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(this.driver, waitForElement);
         wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(by));
     }
     catch
     {
         throw new TimeoutException(string.Format("Element with locator: {0} was not found in {1} seconds!", by.ToString(), secondsToWait));
     }
 }
开发者ID:TelerikAcademy,项目名称:QA-Academy,代码行数:12,代码来源:BaseTest.cs

示例5: BuildStillCheckedExceptionText

        private string BuildStillCheckedExceptionText(By by, BaseTestDriver ext)
        {
            StringBuilder sb = new StringBuilder();

            string customLoggingMessage =
                String.Format("#### The element with the location strategy:  {0} ####\n ####WAS CHECKED!####",
                    by.ToString());
            sb.AppendLine(customLoggingMessage);

            string cuurentUrlMessage = String.Format("The URL when the test failed was: {0}", ext.Browser.Url);
            sb.AppendLine(cuurentUrlMessage);

            return sb.ToString();
        }
开发者ID:Termininja,项目名称:TelerikAcademy,代码行数:14,代码来源:StillCheckedException.cs

示例6: BuildElementStillVisibleExceptionText

        private string BuildElementStillVisibleExceptionText(By by, BaseWebDriverTest ext)
        {
            StringBuilder sb = new StringBuilder();

            string customLoggingMessage =
                String.Format("#### The element with the location strategy:  {0} ####\n ####IS STILL VISIBLE!####",
                    by.ToString());
            sb.AppendLine(customLoggingMessage);

            string cuurentUrlMessage = String.Format("The URL when the test failed was: {0}", ext.Browser.Url);
            sb.AppendLine(cuurentUrlMessage);

            return sb.ToString();
        }
开发者ID:kennedykinyanjui,项目名称:Projects,代码行数:14,代码来源:ElementStillVisibleException.cs

示例7: IsElementNotDisplayed

 public bool IsElementNotDisplayed(By element)
 {
     try
     {
         Driver.FindElement(element);
         return false;
     }
     catch (NoSuchElementException e)
     {
         return true;
     }
     catch (Exception e)
     {
         Console.WriteLine("Something is wrong came to exception instead of NoSuchelementException -- IsElementNotDisplayed({0}) -- Exception >> {1}",element.ToString(),e.Message);
         return false;
     }
 }
开发者ID:rkkreddy,项目名称:FWTest,代码行数:17,代码来源:BasePage.cs

示例8: WaitForElement

 /**
  * Will wait for a specified web element to appear. If not found
  * an assertion will fail.
  *
  * @param by The description of the element
  * @return The matching element if found.
  */
 public static IWebElement WaitForElement(By by)
 {
     for (int second = 0; ; second++)
     {
         if (second >= timeOut)
         {
             Execute.Assertion.FailWith("Timeout occurred while waiting for: " + by.ToString());
         }
         try
         {
             return GetWebDriver().FindElement(by);
         }
         catch (Exception)
         {
             Thread.Sleep(1000);
         }
     }
 }
开发者ID:GraphWalker,项目名称:graphwalker-example,代码行数:25,代码来源:Helper.cs

示例9: WaitForElement

        public static IWebElement WaitForElement(this IWebDriver driver, By by, TimeSpan timeout)
        {
            var wait = new WebDriverWait(driver, timeout);

            return wait.Until((d) =>
            {
                var value = default(IWebElement);

                try
                {
                    value = d.FindElement(by);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Error detected while locating element {0}: ", by.ToString(), e.Message);
                }

                return value;
            });
        }
开发者ID:c0d3m0nky,项目名称:mty,代码行数:20,代码来源:Extensions.cs

示例10: WaitForNotChecked

        public void WaitForNotChecked(By by)
        {
            IWebElement currentElement = this.GetElement(by);
            bool isSelected = currentElement.Selected;

            if (!isSelected)
            {
                Log.ErrorFormat("The element with find expression {0} was checked.", by.ToString());
                throw new StillCheckedException(by, this);
            }
        }
开发者ID:Termininja,项目名称:TelerikAcademy,代码行数:11,代码来源:BaseTestDriver.cs

示例11: setBy

 /// <summary>
 ///     Defines the locator parts ("How" and "Using"), sets the current By locator and uses that By locator to set the current element
 /// </summary>
 /// <param name="by">Current By value</param>
 public void setBy(By by)
 {
     //Split the By locator into the "How" and "Using" parts
     arrLocator = by.ToString().Split(':');
     this.by = by;
     //Set the current element
     this.element = getDriver().FindElement(getBy());
 }
开发者ID:waitsavery,项目名称:Selenium_CS_Using_Bys,代码行数:12,代码来源:Element.cs

示例12: WaitForNotVisible

 public static void WaitForNotVisible(this IWebDriver driver, By by, int timeout = 0)
 {
     if (timeout == 0) timeout = Config.Settings.runTimeSettings.ElementTimeoutSec;
     var then = DateTime.Now.AddSeconds(timeout);
     for (var now = DateTime.Now; now < then; now = DateTime.Now)
     {
         var eles = driver.FindElements(by);
         if (eles.Count == 0 || !eles[0].Displayed)
             return;
         Common.Delay(1000);
     }
     throw new ElementNotVisibleException(string.Format("Element ({0}) was still visible after {1} seconds",
         by.ToString(), timeout));
 }
开发者ID:tokarthik,项目名称:ProtoTest.Golem,代码行数:14,代码来源:WebDriverExtensions.cs

示例13: ReadElementAttributes

        internal static Dictionary<string, string> ReadElementAttributes(By by, IWebDriver webDriver)
        {
            /*
             *
                [
                  {
                    "Key": "href",
                    "Value": "http://example.com"
                  },
                  {
                    "Key": "class",
                    "Value": " "
                  }
                ]
            */

            var result = new Dictionary<string, string>();

            var elements = webDriver.FindElements(by);

            if (elements.Count == 0)
            {
                throw new NotFoundException("ReadElementAttributes: Element was not found" + by.ToString());
            }

            var currentElement = elements[0];

            IJavaScriptExecutor jsExec = webDriver as IJavaScriptExecutor;
            string json = (string)jsExec.ExecuteScript(
            @"
                var jsonResult = ""[\n"";

                var attrs = arguments[0].attributes;
                for (var l = 0; l < attrs.length; ++l) {
                    var a = attrs[l];

                    var name  = a.name.replace(/\\/g, ""\\\\"").replace(/\""/g, ""\\\"""");
                    var value = a.value.replace(/\\/g, ""\\\\"").replace(/\""/g, ""\\\"""");

                    jsonResult += '{ ""Key"": ""' + name + '"", ""Value"": ""' + value + '""},';

                }
                jsonResult += ""]\n"";

                return jsonResult;

            ", currentElement);

            MyLog.Write("JSON:\n" + json);

            var attributesList = DeserializeAttributesFromJson(json);

            foreach (var attr in attributesList)
            {
                result.Add(attr.Key, attr.Value);
            }

            result.Add("TagName", currentElement.TagName);

            return result;
        }
开发者ID:sergueik,项目名称:swd-recorder-appium,代码行数:61,代码来源:JavaScriptUtils.cs

示例14: SelectByText

 /// <summary>Selects an option from a select box based on text
 /// <para> @param by - the by selector for the given element </para>
 /// <para> @param optionText - the text to select by </para>
 /// </summary>
 internal void SelectByText(By by, string optionText)
 {
     if (_logActions)
     {
         _logger.LogMessage(string.Format("Selct: {0}", optionText));
         _logger.LogMessage(string.Format("   at: {0}", by));
     }
     var select = new SelectElement(Find(by));
     if (!select.Equals(null))
     {
         try
         {
             select.SelectByText(optionText);
         }
         catch
         {
             var errMsg = String.Format(
                 "PageObjectBase: There is no option '{0}' in {1}.",
                 optionText, by);
             throw new InvalidSelectOptionException(errMsg);
         }
     }
     else
     {
         string errMsg = "Cannot find element " + by.ToString();
         throw new NoSuchElementException(errMsg);
     }
 }
开发者ID:rohanbaraskar,项目名称:PageObjectFrameworkCSharp,代码行数:32,代码来源:PageObject.cs

示例15: Find

        /// <summary>Finds the element by the given selector
        /// <para> @param by - the by selector for the given element</para>
        /// </summary>
        protected IWebElement Find(By by)
        {
            var _stopwatch = new Stopwatch();
            _stopwatch.Start();
            while (_driver.FindElements(by).Count == 0)
            {
                if (_stopwatch.ElapsedMilliseconds > _defaultTimeout)
                {
                    throw new NoSuchElementException("Could not find element " + by.ToString());
                }
            }
            _stopwatch.Stop();
            _stopwatch.Reset();

            return _driver.FindElement(by);
        }
开发者ID:rohanbaraskar,项目名称:PageObjectFrameworkCSharp,代码行数:19,代码来源:PageObject.cs


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