本文整理汇总了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();
}
示例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);
}
}
示例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);
}
}