本文整理汇总了C#中Browser.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Browser.Dispose方法的具体用法?C# Browser.Dispose怎么用?C# Browser.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Browser
的用法示例。
在下文中一共展示了Browser.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TC01_TestLaunchDispose
public void TC01_TestLaunchDispose()
{
Browser browser = new Browser();
Assert.IsFalse(browser.Opened, "The initial Browser state should be non-opened but it was not!");
Assert.AreEqual(BrowserType.None, browser.BrowserType, "The initial browser type should be None but it was not!");
//Assert.Throws(Exception, browser.WebDriver, "When the browser state is non-opened, getting the WebDriver reference should result in an exception but it did not!");
try
{
// Launch a web browser instance.
browser.Launch(this.browserType);
Assert.IsTrue(browser.Opened, "After successfully launching a web browser instance, the Browser state should be opened but it was not!");
Assert.AreEqual(this.browserType, browser.BrowserType, "After opening a web browser, the current browser type should match but it did not!");
Assert.IsNotNull(browser.WebDriver, "After opening a web browser, the WebDriver reference should not be null but it was!");
}
finally
{
// Always dispose the browser no matter whether it was successfully launched or not.
browser.Dispose();
}
Assert.IsFalse(browser.Opened, "After disposing (i.e., closing the opened web browser instance) the Browser state should be non-opened but it was not!");
Assert.AreEqual(BrowserType.None, browser.BrowserType, "After disposing (i.e., closing the opened web browser instance), the current browser type should be null but it was not!");
//Assert.Throws(Exception, browser.WebDriver, "After disposing (i.e., closing the opened web browser instance), getting the WebDriver reference should result in an exception but it did not!");
// Disposing more than once should be allowed (no exception).
browser.Dispose();
}
示例2: Should_Click_Search_On_Google_And_Return_Results_For_AspNet
public void Should_Click_Search_On_Google_And_Return_Results_For_AspNet(Browser browser)
{
browser.GoTo("http://www.google.co.uk");
browser.TextField(Find.ByName("q")).Value = "asp.net";
browser.Button(Find.ByName("btnG")).Click();
string testString = "The Official Microsoft ASP.NET Site";
browser.WaitUntilContainsText(testString);
Assert.True(browser.ContainsText(testString));
browser.Dispose();
}