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


C# Firefox.FirefoxProfile类代码示例

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


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

示例1: LaunchBrowser

        /// <summary>
        /// Launches the Selenium WebDriver driven browser specified in the Environments.cs file
        /// </summary>
        public IWebDriver LaunchBrowser(IWebDriver driver)
        {
            switch(this.environment.browser)
            {
                case "*firefox":
                    _ffp = new FirefoxProfile();
                    _ffp.AcceptUntrustedCertificates = true;
                    driver = new FirefoxDriver(_ffp);
                    break;
                case "*iexplore":
                    driver = new InternetExplorerDriver();
                    break;
                case "*googlechrome":
                    driver = new ChromeDriver();
                    break;
                case "Android":
                    capabilities = new DesiredCapabilities("android", "", null);
                    capabilities.IsJavaScriptEnabled = true;
                    driver = new RemoteWebDriver(new Uri(string.Format("http://{0}:{1}/hub", environment.host, environment.port)), capabilities);
                    break;
                case "RemoteWebDriver":
                    capabilities = DesiredCapabilities.Firefox();
                    var remoteAddress = new Uri(string.Format("http://{0}:{1}/wd/hub", environment.host, environment.port));
                    driver = new RemoteWebDriver(remoteAddress, capabilities);
                    break;
            }

            return driver;
        }
开发者ID:tmacblane,项目名称:TestManager,代码行数:32,代码来源:WebBrowser.cs

示例2: switch

		/// <summary>
		/// Get a RemoteWebDriver
		/// </summary>
		/// <param name="browser">the Browser to test on</param>
		/// <param name="languageCode">The language that the browser should accept.</param>
		/// <returns>a IWebDriver</returns>
		IWebDriver IWebDriverFactory.GetWebDriver(Browser browser, string languageCode)
		{
			//What browser to test on?s
			IWebDriver webDriver;
			switch (browser.Browserstring.ToLowerInvariant())
			{
				case "firefox":
					var firefoxProfile = new FirefoxProfile();
					firefoxProfile.SetPreference("intl.accept_languages", languageCode);
					webDriver = new FirefoxDriver(firefoxProfile);
					break;
				case "chrome":
					ChromeOptions chromeOptions = new ChromeOptions();
					chromeOptions.AddArguments("--test-type", "--disable-hang-monitor", "--new-window", "--no-sandbox", "--lang=" + languageCode);
					webDriver = new ChromeDriver(chromeOptions);
					break;
				case "internet explorer":
					webDriver = new InternetExplorerDriver(new InternetExplorerOptions { BrowserCommandLineArguments = "singleWindow=true", IntroduceInstabilityByIgnoringProtectedModeSettings = true, EnsureCleanSession = true, EnablePersistentHover = false });
					break;
				case "phantomjs":
					webDriver = new PhantomJSDriver(new PhantomJSOptions() {});
					break;
				default:
					throw new NotSupportedException("Not supported browser");
			}

			return webDriver;
		}
开发者ID:florianwittmann,项目名称:regtesting,代码行数:34,代码来源:LocalWebDriverFactory.cs

示例3: GetLocalDriver

        /// <summary>
        /// ‘абричный метод
        /// </summary>
        /// <param name="browser"></param>
        /// <returns></returns>
        public static RemoteWebDriver GetLocalDriver(string browser)
        {
            InternetExplorerOptions internetExplorerOptions;
            switch (browser)
            {
                case "Chrome":
                    return new ChromeDriver(PathToDriver);

                case "Firefox":
                    var profile = new FirefoxProfile();
                    //profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", ConfigurationManager.AppSettings["SiteIP"]);
                    return new FirefoxDriver(profile);

                case "IE":
                    internetExplorerOptions = new InternetExplorerOptions
                    {
                        IntroduceInstabilityByIgnoringProtectedModeSettings = true,
                        EnableNativeEvents = true
                    };
                    return new InternetExplorerDriver(
                        PathToDriver,
                        internetExplorerOptions);

                default:
                    internetExplorerOptions = new InternetExplorerOptions
                    {
                        IntroduceInstabilityByIgnoringProtectedModeSettings = true,
                        EnableNativeEvents = true
                    };

                    return new InternetExplorerDriver(
                        PathToDriver,
                        internetExplorerOptions);
            }
        }
开发者ID:GulyaevB,项目名称:AcceptanceTesting_demo,代码行数:40,代码来源:BrowserFactory.cs

示例4: GetDriver

        //Start the browser depending on the setting
        public void GetDriver(WebBrowsers webBrws)
        {
            WebBrws = webBrws;
            if (webBrws == WebBrowsers.Ie)
            {
                //Secutiry setting for IE
                var capabilitiesInternet = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true };
                Driver = new InternetExplorerDriver(capabilitiesInternet);
            }
            else
                if (webBrws == WebBrowsers.FireFox)
                {
                    //FirefoxBinary binary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe");
                    FirefoxProfile profile = new FirefoxProfile();
                    // profile.SetPreference("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
                    Driver = new FirefoxDriver(profile);
                }
                else
                    if (webBrws == WebBrowsers.Chrome)
                    {
                        //Chrome driver requires the ChromeDriver.exe
                        Driver = new ChromeDriver(@"..\..\..\lib\BrowserDriver\Chrome");
                    }
                    else { throw new WebDriverException(); }

            Selenium = new WebDriverBackedSelenium(Driver, BaseUrl);
        }
开发者ID:ectechno,项目名称:seshell,代码行数:28,代码来源:BaseClass.cs

示例5: CanBlockInvalidSslCertificates

        //[Test]
        public void CanBlockInvalidSslCertificates()
        {
            FirefoxProfile profile = new FirefoxProfile();
            profile.AcceptUntrustedCertificates = false;
            string url = EnvironmentManager.Instance.UrlBuilder.WhereIsSecure("simpleTest.html");

            IWebDriver secondDriver = null;
            try
            {
                secondDriver = new FirefoxDriver(profile);
                secondDriver.Url = url;
                string gotTitle = secondDriver.Title;
                Assert.AreNotEqual("Hello IWebDriver", gotTitle);
            }
            catch (Exception)
            {
                Assert.Fail("Creating driver with untrusted certificates set to false failed.");
            }
            finally
            {
                if (secondDriver != null)
                {
                    secondDriver.Quit();
                }
            }
        }
开发者ID:v4viveksharma90,项目名称:selenium,代码行数:27,代码来源:FirefoxDriverTest.cs

示例6: TearUp

 public void TearUp()
 {
     FirefoxProfile profile = new FirefoxProfile();
     profile.SetPreference("dom.forms.number", false);
     ff = new FirefoxDriver(profile);
     ff.Navigate().GoToUrl(SITE_PATH);
 }
开发者ID:Galardolind,项目名称:NumericSequenceCalculator,代码行数:7,代码来源:UnitTest1.cs

示例7: InitScenario

 public void InitScenario()
 {
     FirefoxOptions options = new FirefoxOptions();
     var profile = new FirefoxProfile();
     var binary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe");
     driver = new FirefoxDriver(binary, profile);
 }
开发者ID:chauq,项目名称:GoogleTest,代码行数:7,代码来源:GoogleSearchFeatureSteps.cs

示例8: CreateWebDriver

        private static IWebDriver CreateWebDriver()
        {
            IWebDriver driver = null;

            var type = ConfigurationManager.AppSettings["WebDriver"];
            switch (type)
            {
                case "Firefox":
                    {
                        var profile = new FirefoxProfile
                        {
                            AcceptUntrustedCertificates = true,
                            EnableNativeEvents = true
                        };
                        driver = new FirefoxDriver(profile);

                        break;
                    }
                case "InternetExplorer":
                    {
                        // Currently not working
                        var options = new InternetExplorerOptions
                        {
                            IgnoreZoomLevel = true
                        };
                        driver = new InternetExplorerDriver(options);

                        break;
                    }                    
                case "Chrome":
                default:
                    throw new NotSupportedException();
            }
            return driver;
        }
开发者ID:sergiofagostinho,项目名称:netponto.specflow,代码行数:35,代码来源:WebDriverHelper.cs

示例9: Firefox

        private static FirefoxDriver Firefox(NavigatorSessionParameters session)
        {
            var profile = new FirefoxProfile { AcceptUntrustedCertificates = session.AcceptUntrustedCertificates };
            profile.SetPreference("browser.startup.homepage", "about:blank");

            return new FirefoxDriver(profile);
        }
开发者ID:endjin,项目名称:Endjin.SpecFlow.Selenium,代码行数:7,代码来源:WebDriverFactory.cs

示例10: GetDriver

 public static IWebDriver GetDriver(string driver, Devices device)
 {
     DeviceModel model = Device.Get(device);
     IWebDriver webDriver;
     switch (driver.ToLower())
     {
         case "safari":
             webDriver = new SafariDriver();
             break;
         case "chrome":
             webDriver = new ChromeDriver();
             break;
         case "ie":
             webDriver = new InternetExplorerDriver();
             break;
         //case "firefox":
         default:
             var profile = new FirefoxProfile();
             profile.SetPreference("general.useragent.override", model.UserAgent);
             webDriver = new FirefoxDriver(profile);
             webDriver.Manage().Window.Size = model.ScreenSize;
             break;
     }
     return webDriver;
 }
开发者ID:maartenkuijpers,项目名称:SeleniumTemplate,代码行数:25,代码来源:SeleniumDriverHelper.cs

示例11: CreateWebDriver

        private static IWebDriver CreateWebDriver()
        {
            IWebDriver driver = null;

            var type = ConfigurationManager.AppSettings["WebDriver"];
            switch (type)
            {
                case "Firefox":
                    {
                        var firefoxProfile = new FirefoxProfile
                        {
                            AcceptUntrustedCertificates = true,
                            EnableNativeEvents = true
                        };
                        driver = new FirefoxDriver(firefoxProfile);

                        break;
                    }
                case "Chrome":
                case "InternetExplorer":
                    // TODO
                    break;
                default:
                    throw new NotSupportedException();
            }
            return driver;
        }
开发者ID:sergiofagostinho,项目名称:netponto.specflow,代码行数:27,代码来源:WebDriverFactory.cs

示例12: StartDriver

		public static IWebDriver StartDriver (string browserType)
		{
			Trace.WriteLine("Start browser: '" + browserType + "'");

			IWebDriver driver = null;
			switch (browserType)
			{
				case "ie":
					{
						driver = new InternetExplorerDriver("Drivers");
						break;
					}
				case "firefox":
					{
						FirefoxProfile firefoxProfile = new FirefoxProfile();
						firefoxProfile.EnableNativeEvents = true;
						firefoxProfile.AcceptUntrustedCertificates = true;

						driver = new FirefoxDriver(firefoxProfile);
						break;
					}
				case "chrome":
					{
						ChromeOptions chromeOptions = new ChromeOptions();
						chromeOptions.AddArgument("--disable-keep-alive");

						driver = new ChromeDriver("Drivers", chromeOptions);
						break;
					}
			}

			driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
			driver.Manage().Window.Maximize();
			return driver;
		}
开发者ID:rrsc,项目名称:Dnn.Platform,代码行数:35,代码来源:TestBase.cs

示例13: GetFirefoxOptions

 private static FirefoxProfile GetFirefoxOptions()
 {
     FirefoxProfile profile = new FirefoxProfile();
     FirefoxProfileManager manager = new FirefoxProfileManager();
     profile = manager.GetProfile("default");
     return profile;
 }
开发者ID:Saltorel,项目名称:BDD-CSharp,代码行数:7,代码来源:BaseClass.cs

示例14: selects_moved_to_single_method

        public void selects_moved_to_single_method()
        {
            var profile = new FirefoxProfile();
            var exe = new FirefoxBinary(@"D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
            browser = new FirefoxDriver(exe, profile);

            wait = new WebDriverWait(browser,TimeSpan.FromSeconds(10));

            //browser.Navigate().GoToUrl("http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown.aspx");
            browser.Navigate().GoToUrl("http://localhost/AJAXDemos/CascadingDropDown/CascadingDropDown.aspx");

            wait_on_menu_item(1, "Acura");
            select_menu_item(1, "Acura");

            wait_on_menu_item(2, "Integra");
            select_menu_item(2, "Integra");

            wait_on_menu_item(3, "Sea Green");
            select_menu_item(3, "Sea Green");

            wait.Until(
                ExpectedConditions.ElementExists(
                    By.XPath("//span[@id='ctl00_SampleContent_Label1' and text()='You have chosen a Sea Green Acura Integra. Nice car!']")));

            browser.Quit();
        }
开发者ID:jimholmes,项目名称:PresentationDemos,代码行数:26,代码来源:v4_selects_to_separate_method.cs

示例15: GetDriver

        public static IWebDriver GetDriver(DriverType typeOfDriver)
        {
            IWebDriver browser;
            switch (typeOfDriver)
            {
                // NOTE REMOTE DRIVER IS NOT SUPPORTED
                case DriverType.Chrome:
                    ChromeOptions co = new ChromeOptions();
                    browser = new ChromeDriver();
                    break;
                case DriverType.IE:
                    InternetExplorerOptions ieo = new InternetExplorerOptions();
                    browser = new InternetExplorerDriver();
                    break;
                case DriverType.Firefox:    
                default:
                    FirefoxProfile ffp = new FirefoxProfile();
                    ffp.AcceptUntrustedCertificates = true;
                    ffp.Port = 8181;

                    browser = new FirefoxDriver(ffp);
                    break;
            }
            return browser;
        }
开发者ID:kamcio,项目名称:NSeleniumTestRunner,代码行数:25,代码来源:WebDriverFactory.cs


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