本文整理匯總了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();
}