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


C# Browser.ToString方法代码示例

本文整理汇总了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;
        }
开发者ID:megadotnet,项目名称:ironframework,代码行数:36,代码来源:BrowserFactory.cs

示例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());
 }
开发者ID:thomb1,项目名称:SeleniumBasic,代码行数:10,代码来源:BaseBrowsers.cs

示例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());
 }
开发者ID:thomb1,项目名称:SeleniumBasic,代码行数:10,代码来源:BaseBrowsers.cs

示例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;
        }
开发者ID:jesusgarza,项目名称:FluentAutomation,代码行数:38,代码来源:SeleniumWebDriver.cs

示例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.");
        }
开发者ID:jesusgarza,项目名称:FluentAutomation,代码行数:23,代码来源:SeleniumWebDriver.cs

示例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.");
        }
开发者ID:netusers2014,项目名称:FluentAutomation,代码行数:40,代码来源:SeleniumWebDriver.cs


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