當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。