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


C# Browser.Dispose方法代码示例

本文整理汇总了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();
        }
开发者ID:jonchengkuo,项目名称:webui-automation,代码行数:29,代码来源:BrowserTest.cs

示例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();
        }
开发者ID:Nemanja-Spasojevic,项目名称:xUnitBrowserAttribute,代码行数:11,代码来源:Example.cs


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