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


C# By.ToString方法代码示例

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


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

示例1: ElementPresentError

 internal ElementPresentError(By by)
     : base(77, "Element not expected for {0}", by.ToString()) { }
开发者ID:VineGlobal,项目名称:SeleniumBasic,代码行数:2,代码来源:WebRequestErrors.cs

示例2: NoSuchElementError

 internal NoSuchElementError(By by)
     : base(7, "Element not found for {0}", by.ToString()) { }
开发者ID:VineGlobal,项目名称:SeleniumBasic,代码行数:2,代码来源:WebRequestErrors.cs

示例3: ElementNotVisibleError

 internal ElementNotVisibleError(By by)
     : base(7, "Element not visible for {0}", by.ToString()) { }
开发者ID:VineGlobal,项目名称:SeleniumBasic,代码行数:2,代码来源:WebRequestErrors.cs

示例4: ReSort

 /// <summary>
 /// This method will re-sort all the photos inside of the album specified by AlbumID. Note that this is a one-time event, and doesn't apply directly to images added in the future by other means.
 /// </summary>
 /// <param name="b"></param>
 /// <param name="d"></param>
 /// <returns></returns>
 public bool ReSort(By b, Direction d)
 {
     CommunicationHelper ch = new CommunicationHelper();
     // SessionID [required], AlbumID [required], By [required], Direction [required], Callback, Pretty, Strict
     var resp = ch.ExecuteMethod<SmugMugResponse>("smugmug.albums.reSort", basic, "AlbumID", id, "By", b.ToString(), "Direction", d.ToString());
     if (resp.stat == "ok")
         return true;
     else
     {
         Console.WriteLine(resp.message);
         throw new SmugMugException(resp.code, resp.message, resp.method);
     }
 }
开发者ID:mesika,项目名称:mono-smugmug,代码行数:19,代码来源:Album.cs

示例5: VerifyTextBoxEditable

        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        // Description:
        // This method verifies whether a text box is editable or not editable. It does not stop the flow of
        // the test class calling it. It indicates a failure by addding failure message text to the
        // passed-by-ref input string "verificationErrors".
        //
        // Parameters:
        // 1) ExpectedStatus      - Present and displayed or not present and displayed.
        // 2) By                  - The item.
        // 3) VerificationErrors  - Passed by ref for logging errors to error string.
        // 4) Driver              - Web driver handle.
        // 5) WaitTime            - How long to wait for the element to be found.
        // 6) LogError (optional) - Whether to log the eror to the NUnit console (true will log the error).
        //
        // Return:
        // False if expected status is not what is expected and True if expected status is what is expected.
        //
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        public bool VerifyTextBoxEditable(bool ExpectedStatus, By by, ref StringBuilder verificationErrors, IWebDriver driver, int WaitTime, string textToWrite, bool LogError = false)
        {
            Console.WriteLine("    Is Check textbox editable.");
            try // Item passed in should be there. If not, something is wrong to start with.
            {
                WaitForElement(driver, by, WaitTime);
            }
            catch (AssertionException e)
            {
                Console.WriteLine("    !Fail in VerifyTextBoxEditable. Selection that is expected to be present is NOT present. Can not be complete check. Raising a fail. Item = " + by.ToString());
                verificationErrors.Append(e.Message);
                return false;
            }

            try // Try to enter the role name
            {
                IWebElement IWeb = driver.FindElement(by);
                IWeb.SendKeys(textToWrite);
            }
            catch (Exception e)
            {
                // If arrive in this catch, element SendKeys failed because the text box is not editable.
                if (ExpectedStatus == true) // If text box is expected to be editable this is a fail.
                {
                    if (LogError)
                    {
                        Console.WriteLine("    !Fail in VerifyTextBoxEditable. Text box should be editable. Item = " + by.ToString());
                    }
                    verificationErrors.Append(e.Message);
                    return false;
                }
                return true; // Have verified the possible cases with text box not being editable.
            }
            if (ExpectedStatus == false)  // If get here the text box is editable. If caller expects it to NOT be editable there is an error.
            {
                if (LogError)
                {
                    Console.WriteLine("    !Fail in VerifyTextBoxEditable. Text box should NOT be editable. Item = " + by.ToString());
                }
                verificationErrors.Append("!Fail in VerifyTextBoxEditable. Text box should NOT be editable. Item = " + by.ToString());
                return false;
            }
            return true;
        }
开发者ID:sharathannaiah,项目名称:CMP,代码行数:62,代码来源:CommonMethods.cs

示例6: VerifyElementPresentAndDisplayed

 // /////////////////////////////////////////////////////////////////////////////////////////////////////
 // Description:
 // This method verifies whether an item passed to it is present and displayed. It does not stop the
 // flow of the test class calling it. It indicates a failure by addding failure message text to the
 // passed-by-ref input string "verificationErrors".
 //
 // Parameters:
 // 1) ExpectedStatus     - Present and displayed or not present and displayed.
 // 2) By                 - The item.
 // 3) VerificationErrors - Passed by ref for logging errors to error string.
 // 4) Driver             - Web driver handle.
 // 5) WaitTime           - How long to wait for the element to be found.
 // 6) LogError           - Whether to log the eror to the NUnit console (true will log the error).
 //
 // Return:
 // False if expected status is not what is expected and True if expected status is what is expected.
 //
 // /////////////////////////////////////////////////////////////////////////////////////////////////////
 public bool VerifyElementPresentAndDisplayed(bool ExpectedStatus, By by, ref StringBuilder verificationErrors, IWebDriver driver, int WaitTime, bool LogError = false)
 {
     Console.WriteLine("    VerifyElementPresentAndDisplayed");
     try
     {
         WaitForElement(driver, by, WaitTime);
     }
     catch (Exception e)
     {
         // If get here the wait above didn't find the element. It's not present.
         if (ExpectedStatus == true) // If it's supposed to be present this is an error.
         {
             if (LogError == true)
             {
                 Console.WriteLine("    !Fail in VerifyElementPresentAndDisplayed. Item is expected to be present and is not. Item = " + by.ToString());
             }
             verificationErrors.Append(e.Message);
             return false;
         }
         return true; // Expected status is false (element not present). Return without creating/logging an error.
     }
     try
     {
         // Element has been found (is present). See if it's displayed status matches what's expected.
         IWebElement IWeb = driver.FindElement(by);
         Assert.AreEqual(ExpectedStatus, IWeb.Displayed);
     }
     catch (AssertionException e)
     {
         // If get here, displayed status does not match what's expected. Log correct error.
         if (LogError == true)
         {
             if (ExpectedStatus == true)
             {
                 Console.WriteLine("    !Fail in VerifyElementPresentAndDisplayed. Selection expected to be displayed but is not. Item = " + by.ToString());
             }
             else
             {
                 Console.WriteLine("    !Fail in VerifyElementPresentAndDisplayed. Selection expected to not be displayed but is displayed. Item = " + by.ToString());
             }
         }
         verificationErrors.Append(e.Message);
         return false;
     }
     return true; // No failure for displayed status.
 }
开发者ID:sharathannaiah,项目名称:CMP,代码行数:64,代码来源:CommonMethods.cs

示例7: VerifyElementEnabled

 // /////////////////////////////////////////////////////////////////////////////////////////////////////
 // Description:
 // This method verifies whether an item passed in is enabled or not enabled, as long as it exists
 // on the page. The element passed in is expacted to be found. It does not stop the flow of the
 // test class calling it. It indicates a failure by adding a failure message text to the
 // passed-by-ref input string "verificationErrors".
 //
 // Parameters:
 // 1) ExpectedStatus      - Present and displayed or not present and displayed.
 // 2) By                  - The item.
 // 3) VerificationErrors  - Passed by ref for logging errors to error string.
 // 4) Driver              - Web driver handle.
 // 5) WaitTime            - How long to wait for the element to be found.
 // 6) LogError (optional) - Whether to log the eror to the NUnit console (true will log the error).
 //
 // Return:
 // False if expected status is not what is expected and True if expected status is what is expected.
 //
 // /////////////////////////////////////////////////////////////////////////////////////////////////////
 public bool VerifyElementEnabled(bool ExpectedStatus, By by, ref StringBuilder verificationErrors, IWebDriver driver, int WaitTime, bool LogError = false)
 {
     Console.WriteLine("    Check element enabled.");
     try
     {
         WaitForElement(driver, by, WaitTime); // Wait time to avoid intermittent results.
     }
     catch (AssertionException e)
     {
         if (LogError) // If get here there's something wrong. The element is first expected to be found.
         {
             Console.WriteLine("    !Fail in VerifyElementEnabled. Element was expected to be found but was not. Can not be complete check. Raising a fail. Item=" + by.ToString());
         }
         verificationErrors.Append(e.Message);
         return false;
     }
     try
     {
         IWebElement IWeb = driver.FindElement(by);
         Assert.AreEqual(ExpectedStatus, IWeb.Enabled);
     }
     // If get here the expected status is not what is expected. Error will be added to verificationErrors string.
     catch (AssertionException e)
     {
         if (LogError)
         {
             if (ExpectedStatus == true)
             {
                 Console.WriteLine("    !Fail in VerifyElementEnabled. Selection expected to be enabled but is NOT enabled. Item = " + by.ToString());
             }
             else
             {
                 Console.WriteLine("    !Fail in VerifyElementEnabled. Selection expected to NOT be enabled but it is. Item = " + by.ToString());
             }
         }
         verificationErrors.Append(e.Message);
         return false;
     }
     return true; // No error.
 }
开发者ID:sharathannaiah,项目名称:CMP,代码行数:59,代码来源:CommonMethods.cs


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