本文整理汇总了C#中IWebDriver.GetJavaScriptErrors方法的典型用法代码示例。如果您正苦于以下问题:C# IWebDriver.GetJavaScriptErrors方法的具体用法?C# IWebDriver.GetJavaScriptErrors怎么用?C# IWebDriver.GetJavaScriptErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWebDriver
的用法示例。
在下文中一共展示了IWebDriver.GetJavaScriptErrors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.");
}
}
}