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


C# FirefoxProfile.ToBase64String方法代码示例

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


在下文中一共展示了FirefoxProfile.ToBase64String方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoCreate

        protected override Browser DoCreate(Configuration cfg)
        {
            if (cfg == null)
            {
                cfg = new Configuration();
            }

            string name = cfg.Get("PiroPiro.Selenium.Driver");

            if (string.IsNullOrEmpty(name))
            {
                throw new Exception("PiroPiro.Selenium.Driver setting is required");
            }

            string remoteAddress = cfg.Get("PiroPiro.Selenium.Remote.Address", false);

            RemoteWebDriver driver = null;
            bool isLocal = true;

            if (string.IsNullOrEmpty(remoteAddress))
            {
                // use a browser in the local machine

                switch (name.ToLower())
                {
                    case "ie":
                    case "internetexplorer":
                    case "internet explorer":
                        driver = new InternetExplorerDriver();
                        break;
                    case "firefox":
                    case "ff":
                        FirefoxProfile ffp = new FirefoxProfile
                        {
                            AcceptUntrustedCertificates = true,
                            AlwaysLoadNoFocusLibrary = true,
                            EnableNativeEvents = true,
                        };
                        string authDomains = cfg.Get("PiroPiro.TrustedAuthDomains", false);
                        if (string.IsNullOrEmpty(authDomains))
                        {
                            authDomains = "localhost";
                        }
                        ffp.SetPreference("browser.sessionstore.enabled", false);
                        ffp.SetPreference("browser.sessionstore.resume_from_crash", false);
                        ffp.SetPreference("network.automatic-ntlm-auth.trusted-uris", authDomains);
                        driver = new FirefoxDriver(ffp);
                        break;
                    case "chrome":
                        driver = new ChromeDriver(GetChromeDriverDir(cfg));
                        break;
                    default:
                        throw new Exception("Selenium Driver not supported: " + name);
                }
            }
            else
            {
                // use a browser in a remote machine
                isLocal = false;

                string version = cfg.Get("PiroPiro.Selenium.Remote.Version", false);
                if (string.IsNullOrEmpty(version))
                {
                    version = null;
                }
                string platform = cfg.Get("PiroPiro.Selenium.Remote.Platform", false);
                if (string.IsNullOrEmpty(platform))
                {
                    platform = "Any";
                }

                if (name.ToLower().Trim() == "htmlunit" && string.IsNullOrWhiteSpace(version))
                {
                    // tell htmlunit by default to behave like firefox
                    version = "firefox";
                }

                DesiredCapabilities cap = new OpenQA.Selenium.Remote.DesiredCapabilities(name, version, new Platform((PlatformType)Enum.Parse(typeof(PlatformType), platform)));

                // enable javascript by default
                cap.IsJavaScriptEnabled = true;

                if (name.ToLower().Trim() == "firefox")
                {
                    // if firefox, add some preferences

                    string authDomains = cfg.Get("PiroPiro.TrustedAuthDomains", false);
                    if (string.IsNullOrEmpty(authDomains))
                    {
                        authDomains = "localhost";
                    }

                    FirefoxProfile ffp = new FirefoxProfile();
                    ffp.SetPreference("browser.sessionstore.enabled", false);
                    ffp.SetPreference("browser.sessionstore.resume_from_crash", false);
                    ffp.SetPreference("network.automatic-ntlm-auth.trusted-uris", authDomains);

                    cap.SetCapability(FirefoxDriver.ProfileCapabilityName, ffp.ToBase64String());
                }

//.........这里部分代码省略.........
开发者ID:benjamine,项目名称:PiroPiro,代码行数:101,代码来源:SeleniumBrowserFactory.cs


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