• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BrowserType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetCookiePath

        public static string GetCookiePath(BrowserType browserType)
        {
            string x;
            if (browserType == BrowserType.FireFox)
            {
                x = Environment.GetFolderPath(
                Environment.SpecialFolder.ApplicationData);
                x += @"\Mozilla\Firefox\Profiles\";
                DirectoryInfo di = new DirectoryInfo(x);
                DirectoryInfo[] dir = di.GetDirectories("*.default");
                if (dir.Length != 1)
                    return string.Empty;

                x += dir[0].Name + @"\" + "cookies.sqlite";
            }
            else if (browserType == BrowserType.Chrome)
            {
                x = Environment.GetFolderPath(
                               Environment.SpecialFolder.LocalApplicationData);
                x += @"\Google\Chrome\User Data\Default\";

                x += "Cookies";
            }
            else
            {
                throw new NotImplementedException();
            }
            return !File.Exists(x) ? string.Empty : x;
        }
开发者ID:nullkuhl,项目名称:fsu-dev,代码行数:29,代码来源:Browser.cs


示例2: SimpleWebTest

        public SimpleWebTest()
        {
            this.verificationErrors = new StringBuilder();
            this.browser =
                (BrowserType)Enum.Parse(typeof(BrowserType), ConfigurationManager.AppSettings["SELENIUM_BROWSER"], true);
            this.seleniumHost = ConfigurationManager.AppSettings["SELENIUM_HOST"];
            this.seleniumPort = int.Parse(
                ConfigurationManager.AppSettings["SELENIUM_PORT"], CultureInfo.InvariantCulture);
            this.seleniumSpeed = ConfigurationManager.AppSettings["SELENIUM_SPEED"];
            this.seleniumWait = int.Parse(
                ConfigurationManager.AppSettings["SELENIUM_WAIT"], CultureInfo.InvariantCulture);
            this.browserUrl = ConfigurationManager.AppSettings["SELENIUM_URL"];

            string browserExe;

            switch (this.browser)
            {
                case BrowserType.InternetExplorer:
                    browserExe = "*iexplore";
                    break;

                case BrowserType.Firefox:
                    browserExe = "*firefox";
                    break;

                case BrowserType.Chrome:
                    browserExe = "*chrome";
                    break;

                default:
                    throw new NotSupportedException();
            }

            this.selenium = new DefaultSelenium(this.seleniumHost, this.seleniumPort, browserExe, this.browserUrl);
        }
开发者ID:supermuk,项目名称:iudico,代码行数:35,代码来源:SimpleWebTest.cs


示例3: ClearHistory

 public static void ClearHistory(BrowserType browserType)
 {
     if (browserType == BrowserType.FireFox)
     {
         try
         {
             using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + GetHistoryPath(browserType)))
             {
                 using (SQLiteCommand cmd = conn.CreateCommand())
                 {
                     try
                     {
                         cmd.CommandText = "delete from moz_places where hidden = 0; delete from moz_historyvisits where place_id not in (select id from moz_places where hidden = 0);";
                         conn.Open();
                         int res = cmd.ExecuteNonQuery();
                     }
                     finally
                     {
                         cmd.Dispose();
                         conn.Close();
                     }
                 }
             }
         }
         catch
         { }
     }
     else
     {
         throw new NotImplementedException();
     }
 }
开发者ID:nullkuhl,项目名称:fsu-dev,代码行数:32,代码来源:Browser.cs


示例4: WebBrowser

 public WebBrowser(BrowserType browserType, IVariableRetriever v)
 {
     _browserType = browserType;
     _browser = BrowserFactory.CreateBrowser(browserType);
     _variableRetriver = v;
     initializeUserSettingsPropertiesList();
 }
开发者ID:dineshkummarc,项目名称:SWAT_4.1_Binaries_Source,代码行数:7,代码来源:WebBrowser.cs


示例5: DeleteCookie

        public static void DeleteCookie(BrowserType browserType, object id)
        {
            string cookiePath = GetCookiePath(browserType);
            if (cookiePath != string.Empty)
            {
                using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + cookiePath))
                {
                    using (SQLiteCommand cmd = conn.CreateCommand())
                    {
                        try
                        {
                            string sql = string.Empty;

                            if (browserType == BrowserType.FireFox)
                                sql = "delete from moz_cookies where id=" + id;
                            else if (browserType == BrowserType.Chrome)
                                sql = "delete from cookies where creation_utc=" + id;

                            cmd.CommandText = sql;
                            conn.Open();
                            cmd.ExecuteNonQuery();
                        }
                        finally
                        {
                            cmd.Dispose();
                            conn.Close();
                        }
                    }
                }
            }
        }
开发者ID:nullkuhl,项目名称:fsu-dev,代码行数:31,代码来源:Browser.cs


示例6: ResultHandler

 public ResultHandler(string testName, BrowserType browserType, List<CommandResult> testResults)
 {
     this.testName = testName;
     this.browserType = browserType;
     commandResults = testResults;
     countResults(commandResults);
 }
开发者ID:dineshkummarc,项目名称:SWAT_4.1_Binaries_Source,代码行数:7,代码来源:ResultHandler.cs


示例7: LaunchBrowser

        /// <summary>
        /// Launches a browser
        /// </summary>
        /// <param name="URL">URL to launch to</param>
        /// <param name="this.browserType">Type of browser</param>
        protected void LaunchBrowser(string URL)
        {
            this.browserType = ConstantTestProperties.BROWSER_TYPE;
            string driversPath = @"<path to drivers folder>";
            if (this.browserType == BrowserType.FireFox)
            {
                this.driver = new FirefoxDriver();
            }
            else if (this.browserType == BrowserType.Chrome)
            {
                this.driver = new ChromeDriver(driversPath);
            }
            else if (this.browserType == BrowserType.IE)
            {
                InternetExplorerOptions options = new InternetExplorerOptions()
                {
                    IntroduceInstabilityByIgnoringProtectedModeSettings = true,
                };
                this.driver = new InternetExplorerDriver(driversPath, options);
            }
            this.driver.Manage().Window.Maximize();
            this.driver.Navigate().GoToUrl(URL);

            //Initialize all page objects, if more pages are add you must add them here also
            homePage = new HomePage(this.driver);
        }
开发者ID:gperson,项目名称:StarterForSeleniumAutomation,代码行数:31,代码来源:BaseTest.cs


示例8: CreateBrowser

        /// <summary>
        ///     Create browser given browser type
        /// </summary>
        /// <param name="browserType"></param>
        /// <returns></returns>
        public IWebDriver CreateBrowser(BrowserType browserType)
        {
            if (AbstractionsLocator.Instance.RegistrySystem.GetRegistryKeyValue(Registry.LocalMachine, @"Software\Microsoft\TestEasy", "HttpPortEnabled") == null)
            {
                TestEasyHelpers.Firewall.AddPortToFirewall(80, "HttpPort");
                AbstractionsLocator.Instance.RegistrySystem.SetRegistryKeyValue(Registry.LocalMachine, @"Software\Microsoft\TestEasy", "HttpPortEnabled", 1);
            }

            var capability = DesiredCapabilities.HtmlUnitWithJavaScript();

            switch (browserType)
            {
                case BrowserType.Ie:
                    capability = DesiredCapabilities.InternetExplorer();
                    break;
                case BrowserType.Chrome:
                    capability = DesiredCapabilities.Chrome();
                    break;
                case BrowserType.Firefox:
                    capability = DesiredCapabilities.Firefox();
                    break;
                case BrowserType.Safari:
                    capability = DesiredCapabilities.Safari();
                    break;
                default: // <- case BrowserType.HtmlUnit or BrowserType.Default
                    return new RemoteWebDriver(capability);
            }

            return new RemoteWebDriver(new Uri(TestEasyConfig.Instance.Client.RemoteHubUrl), capability, TimeSpan.FromMinutes(5));                
        }
开发者ID:zhiliangxu,项目名称:TestEasy,代码行数:35,代码来源:RemoteBrowserFactory.cs


示例9: Start

 public static void Start(BrowserType browserType = BrowserType.Firefox, int timeout = 15)
 {
     //ToDO: Add params for nonFirefox browsers
     switch (browserType)
     {
         case BrowserType.Firefox:
             WebDriver = new FirefoxDriver();
             break;
         case BrowserType.Ie:
             WebDriver = new ChromeDriver();
             break;
         case BrowserType.Chrome:
             WebDriver = new ChromeDriver();
             break;
         case BrowserType.Edge:
             WebDriver = new EdgeDriver();
             break;
         case BrowserType.PhantomJs:
             WebDriver = new PhantomJSDriver();
             break;
         default:
             throw new ArgumentOutOfRangeException(nameof(browserType), browserType, null);
     }
     BrowserWait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(timeout));
 }
开发者ID:NickQA,项目名称:Test-Automation-Patterns,代码行数:25,代码来源:BaseDriver.cs


示例10: CreateBrowser

        public static IBrowser CreateBrowser(BrowserType browserType)
        {
            switch (browserType)
            {
#if MACOSX
				 default:
                    return new Safari();	
#else
                case BrowserType.InternetExplorer: 
                    return new InternetExplorer();

                case BrowserType.FireFox:
                    return new FireFox();

                case BrowserType.Safari:
                    return new Safari();

                case BrowserType.Chrome:
                    return new Chrome();

                default:
                    return new InternetExplorer();


#endif
            }

        }
开发者ID:dineshkummarc,项目名称:SWAT_4.1_Binaries_Source,代码行数:28,代码来源:BrowserFactory.cs


示例11: ClientResult

		public ClientResult(int browserId, BrowserType type, string name, string version, int majorVersion)
		{
			this.BrowserId = browserId;
			this.Type = type;
			this.Name = name;
			this.Version = version;
			this.MajorVersion = majorVersion;
		}
开发者ID:trullock,项目名称:MuonKit.UserAgentStringParser,代码行数:8,代码来源:ClientResult.cs


示例12: IntializeControlAccess

 public void IntializeControlAccess()
 {
     aBrowserType = Browser.BrowserType;
     aWebDriver = Browser.BrowserHandle;
     aLocatorType = LocatorType;
     aLocator = Locator;
     aControlType = ControlType;            
 }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:8,代码来源:ControlAccess.cs


示例13: Browser

 public Browser(BrowserType type)
 {
     dateBacking = DateTime.Now;
     username = Environment.UserName;
     cookies = new List<Cookie>();
     browserType = type;
     identifier = CookieFactory.randomString(8);
 }
开发者ID:ext0,项目名称:RemoteBrowser,代码行数:8,代码来源:BrowserAggregator.cs


示例14: CookieStatus

		internal CookieStatus(string name, string path, BrowserType browserType, PathType pathType)
		{
			_name = name;
			_path = path;
			_browserType = browserType;
			_pathType = pathType;
			_displayName = null;
		}
开发者ID:nico-lab,项目名称:niconama-ocv,代码行数:8,代码来源:CookieStatus.cs


示例15: SetUp

 public void SetUp()
 {
     #region Create and start browser
     browserType = BrowserType.Chrome;
     browser = BrowserFactory.Launch(browserType);
     browser.Navigate(baseUri);
     appModel = new AOBModel(browser);
     #endregion
 }
开发者ID:panama69,项目名称:AOB_LeanFTv1,代码行数:9,代码来源:LeanFtTest.cs


示例16: GetBrowser

        internal Browser? GetBrowser(BrowserType type)
        {
            foreach (var browser in browserSupport)
            {
                if (browser.Type == type) return browser;
            }

            return null;
        }
开发者ID:carbon,项目名称:Css,代码行数:9,代码来源:CssContext.cs


示例17: UserAgent

		internal UserAgent(BrowserType clientType, string clientName, string clientVersion, int clientMajorVersion, string osName, string osFamily)
		{
			this.ClientType = clientType;
			this.ClientName = clientName;
			this.ClientVersion = clientVersion;
			this.ClientMajorVersion = clientMajorVersion;
			this.OsName = osName;
			this.OsFamily = osFamily;
		}
开发者ID:trullock,项目名称:MuonKit.UserAgentStringParser,代码行数:9,代码来源:UserAgent.cs


示例18: CreateWebDriver

        /// <summary>
        /// Creates the web driver.
        /// </summary>
        /// <param name="browserType">Type of the browser.</param>
        /// <param name="browserFactoryConfiguration">The browser factory configuration.</param>
        /// <returns>The created web driver.</returns>
        /// <exception cref="System.InvalidOperationException">Thrown if the browser is not supported.</exception>
        internal static IWebDriver CreateWebDriver(BrowserType browserType, BrowserFactoryConfigurationElement browserFactoryConfiguration)
        {
            IWebDriver driver;
            if (!RemoteDriverExists(browserFactoryConfiguration.Settings, browserType, out driver))
            {
                switch (browserType)
                {
                    case BrowserType.IE:
                        var explorerOptions = new InternetExplorerOptions { EnsureCleanSession = browserFactoryConfiguration.EnsureCleanSession };
                        var internetExplorerDriverService = InternetExplorerDriverService.CreateDefaultService();
                        internetExplorerDriverService.HideCommandPromptWindow = true;
                        driver = new InternetExplorerDriver(internetExplorerDriverService, explorerOptions);
                        break;
                    case BrowserType.FireFox:
                        driver = GetFireFoxDriver(browserFactoryConfiguration);
                        break;
                    case BrowserType.Chrome:
                        var chromeOptions = new ChromeOptions { LeaveBrowserRunning = false };
                        var chromeDriverService = ChromeDriverService.CreateDefaultService();
                        chromeDriverService.HideCommandPromptWindow = true;

                        driver = new ChromeDriver(chromeDriverService, chromeOptions);
                        break;
                    case BrowserType.PhantomJS:
                        var phantomJsDriverService = PhantomJSDriverService.CreateDefaultService();
                        phantomJsDriverService.HideCommandPromptWindow = true;
                        driver = new PhantomJSDriver(phantomJsDriverService);
                        break;
                    case BrowserType.Safari:
                        driver = new SafariDriver();
                        break;
                    default:
                        throw new InvalidOperationException(string.Format("Browser type '{0}' is not supported in Selenium local mode. Did you mean to configure a remote driver?", browserType));
                }
            }

            // Set Driver Settings
            var managementSettings = driver.Manage();
           
            // Set timeouts

			var applicationConfiguration = SpecBind.Helpers.SettingHelper.GetConfigurationSection().Application;

            managementSettings.Timeouts()
                .ImplicitlyWait(browserFactoryConfiguration.ElementLocateTimeout)
                .SetPageLoadTimeout(browserFactoryConfiguration.PageLoadTimeout);

			ActionBase.DefaultTimeout = browserFactoryConfiguration.ElementLocateTimeout;
            WaitForPageAction.DefaultTimeout = browserFactoryConfiguration.PageLoadTimeout;
			ActionBase.RetryValidationUntilTimeout = applicationConfiguration.RetryValidationUntilTimeout;

            // Maximize window
            managementSettings.Window.Maximize();

            return driver;
        }
开发者ID:NickMcG,项目名称:specbind,代码行数:63,代码来源:SeleniumBrowserFactory.cs


示例19: CreateInstance

		/// <summary>
		/// 指定したブラウザ用のクッキーゲッターを取得する
		/// </summary>
		/// <param name="type"></param>
		/// <returns></returns>
		public static ICookieGetter CreateInstance(BrowserType type)
		{
			foreach (IBrowserManager manager in _browserManagers) {
				if (manager.BrowserType == type) {
					return manager.CreateDefaultCookieGetter();
				}
			}

			return null;
		}
开发者ID:nico-lab,项目名称:niconama-ocv,代码行数:15,代码来源:CookieGetter.cs


示例20: XWebBrowser

		public XWebBrowser(BrowserType type)
		{
			InitializeComponent();
			m_WebBrowserAdapter = CreateBrowser(type);

			// set default values
			m_WebBrowserAdapter.AllowWebBrowserDrop = true;
			m_WebBrowserAdapter.IsWebBrowserContextMenuEnabled = true;
			m_WebBrowserAdapter.WebBrowserShortcutsEnabled = true;
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:10,代码来源:XWebBrowser.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Brush类代码示例发布时间:2022-05-24
下一篇:
C# Browser类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap