示例#1
0
        public static IISExpressDriver StartServer()
        {
            var physicalDirectory =
                Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                    Settings.Default.SimpleServerPath));

            var applicationConfigPath =
                Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "applicationhost.config"));

            var actualConfigPath =
                Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "applicationhost.fixed.config"));

            var appDataPath = Path.Combine(physicalDirectory, "App_Data");
            foreach(string file in Directory.GetFiles(appDataPath, "*"))
            {
                File.Delete(file);

                if (File.Exists(file))
                    throw new Exception("unable to delete file " + file);
            }

            var originalConfig = File.ReadAllText(applicationConfigPath);

            var originalSitePhysicalDirectory = @"C:\src\FBDerp\SimpleWebApplication";

            if (originalConfig.IndexOf(originalSitePhysicalDirectory) == -1)
            {
                throw new Exception("Did not find replacement target for physical directory in applicationhost.config");
            }

            var newConfig = originalConfig.Replace(originalSitePhysicalDirectory, physicalDirectory);

            File.WriteAllText(actualConfigPath, newConfig);

            var serverDriver = new IISExpressDriver();

            serverDriver.StartWithConfigurationFile(actualConfigPath);

            return serverDriver;
        }
示例#2
0
        private void go_to_registration_form(ChromeDriver browser, IISExpressDriver site)
        {
            browser.Navigate().GoToUrl(site.UrlFor("/Account/Register"));

            var iframe =
                browser.WaitForElementEx(
                    BySizzle.CssSelector("iframe[src^=\"https://www.facebook.com/plugins/registration.php\"]"),
                    Constants.MSLongWait);

            browser.SwitchTo().Frame(iframe);
        }