コード例 #1
0
        public void TestMethod()
        {
            Dictionary <string, string> dict = BrowserSetUp.getFireFoxProfile();

            foreach (var item in dict)
            {
                Console.WriteLine(item.Key + "  " + item.Value);
            }
        }
コード例 #2
0
        public void SetUpBrowswer()
        {
            if (BrowserSetUp.getBrowserName().ToLower().StartsWith("fire"))
            {
                Dictionary <string, string> dictffprofile = BrowserSetUp.getFireFoxProfile();
                if (dictffprofile.Count != 0)
                {
                    FirefoxOptions ffoptions = new FirefoxOptions();
                    foreach (var item in dictffprofile)
                    {
                        if (item.Value.ToString().Equals("true") || item.Value.ToString().Equals("false"))
                        {
                            Boolean value = item.Value.ToString().Equals("true") ? true : false;
                            ffoptions.SetPreference(item.Key, value);
                        }
                        else
                        {
                            ffoptions.SetPreference(item.Key, item.Value);
                        }
                    }
                    driver = new FirefoxDriver(ffoptions);
                }
                else
                {
                    driver = new FirefoxDriver();
                }
            }
            else if (BrowserSetUp.getBrowserName().ToLower().StartsWith("chrome"))
            {
                ChromeOptions choptions = new ChromeOptions();
                choptions.AddArguments(BrowserSetUp.GetChromeOption());
                driver = new ChromeDriver(choptions);
            }

            driver.Navigate().GoToUrl(BrowserSetUp.getUrlApplication());
            driver.Manage().Window.Maximize();
            driver.Manage().Cookies.DeleteAllCookies();
        }