本文整理汇总了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.");
}
}
}
示例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);
}