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


C# Browser.Launch方法代码示例

本文整理汇总了C#中Browser.Launch方法的典型用法代码示例。如果您正苦于以下问题:C# Browser.Launch方法的具体用法?C# Browser.Launch怎么用?C# Browser.Launch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Browser的用法示例。


在下文中一共展示了Browser.Launch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: TC02_TestBasicNavigationAndFind

 public void TC02_TestBasicNavigationAndFind()
 {
     using (Browser browser = new Browser())
     {
         browser.Launch(this.browserType).NavigateTo("http://www.google.com");
         IWebElement searchBox = browser.WaitUntil(ExpectedConditions.ElementIsVisible(By.Name("q")), 10);
         searchBox.SendKeys("Selenium");
         searchBox.Submit();
         browser.Sleep(3);
         Assert.AreEqual("Selenium - Google Search", browser.Title);
     }
 }
开发者ID:jonchengkuo,项目名称:webui-automation,代码行数:12,代码来源:BrowserTest.cs

示例3: Main

        static void Main(string[] args)
        {
            string url = "http://google.com";

            using (Browser browser = new Browser())
            {
                browser.Launch(BrowserType.IE).NavigateTo(url);
                IWebElement searchBox = browser.WaitUntil(ExpectedConditions.ElementIsVisible(By.Name("q")), 10);
                searchBox.SendKeys("selenium");
                searchBox.Submit();
                browser.Sleep(5);
            }
        }
开发者ID:jonchengkuo,项目名称:webui-automation,代码行数:13,代码来源:Program.cs


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