當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。