本文整理汇总了C#中Browser.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Browser.ToString方法的具体用法?C# Browser.ToString怎么用?C# Browser.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Browser
的用法示例。
在下文中一共展示了Browser.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBrowserExePath
/// <summary>
/// Resolving a browser exe path based on the Setting.
/// </summary>
/// <param name="browser"><see cref="Broser"/> type.</param>
/// <returns>Path to the exe for specific browser.</returns>
public static string GetBrowserExePath(Browser browser)
{
var path = string.Empty;
var settings = Properties.Settings.Default;
switch (browser)
{
case Browser.IE:
path = settings.IeExePath;
break;
case Browser.Chrome:
path = settings.ChromeExePath;
break;
case Browser.Firefox:
path = settings.FirefoxExePath;
break;
case Browser.Opera:
path = settings.OperaExePath;
break;
default:
path = settings.IeExePath;
break;
}
if (string.IsNullOrWhiteSpace(path))
{
throw new InvalidOperationException(string.Format("Path to the browser exe for {0} can not be empty.", browser.ToString()));
}
return path;
}
示例2: GetBrowserInstance
private WebDriver GetBrowserInstance(Browser browser) {
switch (browser) {
case Browser.Firefox: return new Selenium.FirefoxDriver();
case Browser.Chrome: return new Selenium.ChromeDriver();
case Browser.Opera: return new Selenium.OperaDriver();
case Browser.IE: return new Selenium.IEDriver();
case Browser.PhantomJS: return new Selenium.PhantomJSDriver();
}
throw new Exception("Browser not supported: " + browser.ToString());
}
示例3: GetBrowserTypeLib
private string GetBrowserTypeLib(Browser browser) {
switch (browser) {
case Browser.Firefox: return "Selenium.FirefoxDriver";
case Browser.Chrome: return "Selenium.ChromeDriver";
case Browser.Opera: return "Selenium.OperaDriver";
case Browser.IE: return "Selenium.IEDriver";
case Browser.PhantomJS: return "Selenium.PhantomJSDriver";
}
throw new Exception("Browser not supported: " + browser.ToString());
}
示例4: GenerateDesiredCapabilities
private static DesiredCapabilities GenerateDesiredCapabilities(Browser browser)
{
DesiredCapabilities browserCapabilities = null;
switch (browser)
{
case Browser.InternetExplorer:
case Browser.InternetExplorer64:
browserCapabilities = DesiredCapabilities.InternetExplorer();
break;
case Browser.Firefox:
browserCapabilities = DesiredCapabilities.Firefox();
break;
case Browser.Chrome:
browserCapabilities = DesiredCapabilities.Chrome();
break;
case Browser.PhantomJs:
browserCapabilities = DesiredCapabilities.PhantomJS();
break;
case Browser.Safari:
browserCapabilities = DesiredCapabilities.Safari();
break;
case Browser.iPad:
browserCapabilities = DesiredCapabilities.IPad();
break;
case Browser.iPhone:
browserCapabilities = DesiredCapabilities.IPhone();
break;
case Browser.Android:
browserCapabilities = DesiredCapabilities.Android();
break;
default:
throw new FluentException("Selected browser [{0}] not supported. Unable to determine appropriate capabilities.", browser.ToString());
}
browserCapabilities.IsJavaScriptEnabled = true;
return browserCapabilities;
}
示例5: GenerateBrowserSpecificDriver
private static Func<IWebDriver> GenerateBrowserSpecificDriver(Browser browser)
{
string driverPath = string.Empty;
switch (browser)
{
case Browser.InternetExplorer:
driverPath = EmbeddedResources.UnpackFromAssembly("IEDriverServer32.exe", "IEDriverServer.exe", Assembly.GetAssembly(typeof(SeleniumWebDriver)));
return new Func<IWebDriver>(() => new Wrappers.IEDriverWrapper(Path.GetDirectoryName(driverPath)));
case Browser.InternetExplorer64:
driverPath = EmbeddedResources.UnpackFromAssembly("IEDriverServer64.exe", "IEDriverServer.exe", Assembly.GetAssembly(typeof(SeleniumWebDriver)));
return new Func<IWebDriver>(() => new Wrappers.IEDriverWrapper(Path.GetDirectoryName(driverPath)));
case Browser.Firefox:
return new Func<IWebDriver>(() => new OpenQA.Selenium.Firefox.FirefoxDriver());
case Browser.Chrome:
driverPath = EmbeddedResources.UnpackFromAssembly("chromedriver.exe", Assembly.GetAssembly(typeof(SeleniumWebDriver)));
return new Func<IWebDriver>(() => new OpenQA.Selenium.Chrome.ChromeDriver(Path.GetDirectoryName(driverPath)));
case Browser.PhantomJs:
driverPath = EmbeddedResources.UnpackFromAssembly("phantomjs.exe", Assembly.GetAssembly(typeof(SeleniumWebDriver)));
return new Func<IWebDriver>(() => new OpenQA.Selenium.PhantomJS.PhantomJSDriver(Path.GetDirectoryName(driverPath)));
}
throw new NotImplementedException("Selected browser " + browser.ToString() + " is not supported yet.");
}
示例6: GenerateBrowserSpecificDriver
private static Func<IWebDriver> GenerateBrowserSpecificDriver(Browser browser, TimeSpan commandTimeout)
{
string driverPath = string.Empty;
switch (browser)
{
case Browser.InternetExplorer:
driverPath = EmbeddedResources.UnpackFromAssembly("IEDriverServer32.exe", "IEDriverServer.exe", Assembly.GetAssembly(typeof(SeleniumWebDriver)));
return new Func<IWebDriver>(() => new Wrappers.IEDriverWrapper(Path.GetDirectoryName(driverPath), commandTimeout));
case Browser.InternetExplorer64:
driverPath = EmbeddedResources.UnpackFromAssembly("IEDriverServer64.exe", "IEDriverServer.exe", Assembly.GetAssembly(typeof(SeleniumWebDriver)));
return new Func<IWebDriver>(() => new Wrappers.IEDriverWrapper(Path.GetDirectoryName(driverPath), commandTimeout));
case Browser.Firefox:
return new Func<IWebDriver>(() => {
var firefoxBinary = new OpenQA.Selenium.Firefox.FirefoxBinary();
return new OpenQA.Selenium.Firefox.FirefoxDriver(firefoxBinary, new OpenQA.Selenium.Firefox.FirefoxProfile
{
EnableNativeEvents = false,
AcceptUntrustedCertificates = true,
AlwaysLoadNoFocusLibrary = true
}, commandTimeout);
});
case Browser.Chrome:
driverPath = EmbeddedResources.UnpackFromAssembly("chromedriver.exe", Assembly.GetAssembly(typeof(SeleniumWebDriver)));
var chromeService = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverPath));
chromeService.SuppressInitialDiagnosticInformation = true;
var chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--log-level=3");
return new Func<IWebDriver>(() => new OpenQA.Selenium.Chrome.ChromeDriver(chromeService, chromeOptions, commandTimeout));
case Browser.PhantomJs:
driverPath = EmbeddedResources.UnpackFromAssembly("phantomjs.exe", Assembly.GetAssembly(typeof(SeleniumWebDriver)));
var phantomOptions = new OpenQA.Selenium.PhantomJS.PhantomJSOptions();
return new Func<IWebDriver>(() => new OpenQA.Selenium.PhantomJS.PhantomJSDriver(Path.GetDirectoryName(driverPath), phantomOptions, commandTimeout));
}
throw new NotImplementedException("Selected browser " + browser.ToString() + " is not supported yet.");
}