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


C# IWebDriver.NavigateTo方法代码示例

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


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

示例1: TestJavaScriptErrors

 /// <summary>
 /// Executes the code to test collection of JavaScript errors on the page.
 /// </summary>
 /// <param name="driver">The driver to use with the browser.</param>
 private static void TestJavaScriptErrors(IWebDriver driver)
 {
     // Using Dave Haeffner's the-internet project http://github.com/arrgyle/the-internet,
     // which provides pages that return various HTTP status codes.
     string url = "http://the-internet.herokuapp.com/javascript_error";
     Console.WriteLine("Navigating to {0}", url);
     driver.NavigateTo(url);
     IList<string> javaScriptErrors = driver.GetJavaScriptErrors();
     if (javaScriptErrors == null)
     {
         Console.WriteLine("Could not access JavaScript errors collection. This is a catastrophic failure.");
     }
     else
     {
         if (javaScriptErrors.Count > 0)
         {
             Console.WriteLine("Found the following JavaScript errors on the page:");
             foreach (string javaScriptError in javaScriptErrors)
             {
                 Console.WriteLine(javaScriptError);
             }
         }
         else
         {
             Console.WriteLine("No JavaScript errors found on the page.");
         }
     }
 }
开发者ID:jimevans,项目名称:WebDriverProxyExamples,代码行数:32,代码来源:Program.cs

示例2: TestStatusCodes

        /// <summary>
        /// Executes the code to test retrieval of HTTP status codes from the browser.
        /// </summary>
        /// <param name="driver">The driver to use with the browser.</param>
        private static void TestStatusCodes(IWebDriver driver)
        {
            // Using Dave Haeffner's the-internet project http://github.com/arrgyle/the-internet,
            // which provides pages that return various HTTP status codes.
            string url = "http://the-internet.herokuapp.com/redirect";
            Console.WriteLine("Navigating to {0}", url);
            int responseCode = driver.NavigateTo(url);
            Console.WriteLine("Navigation to {0} returned response code {1}", url, responseCode);

            // Demonstrates navigating to a 404 page.
            url = "http://the-internet.herokuapp.com/redirector";
            Console.WriteLine("Navigating to {0}", url);
            responseCode = driver.NavigateTo(url);
            Console.WriteLine("Navigation to {0} returned response code {1}", url, responseCode);
            string elementId = "redirect";
            Console.WriteLine("Clicking on element with ID {0}", elementId);
            IWebElement element = driver.FindElement(By.Id(elementId));
            responseCode = element.ClickNavigate();
            Console.WriteLine("Element click returned response code {0}", responseCode);

            // Demonstrates navigating to a 404 page.
            url = "http://the-internet.herokuapp.com/status_codes/404";
            Console.WriteLine("Navigating to {0}", url);
            responseCode = driver.NavigateTo(url);
            Console.WriteLine("Navigation to {0} returned response code {1}", url, responseCode);
        }
开发者ID:jimevans,项目名称:WebDriverProxyExamples,代码行数:30,代码来源:Program.cs


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