Task ISubSystem.Start()
        {
            return(Task.Factory.StartNew(() => {
                var settings = StoryTellerEnvironment.Get <SerenityEnvironment>();
                WebDriverSettings.Import(settings);

                FubuMvcPackageFacility.PhysicalRootPath = _settings.PhysicalPath;
                _runtime = _runtimeSource();


                var browserLifecycle = WebDriverSettings.GetBrowserLifecyle(ChooseBrowserType());
                _hosting = _settings.RootUrl.IsEmpty() ? (ISerenityHosting) new KatanaHosting() : new ExternalHosting();

                _application = _hosting.Start(_settings, _runtime, browserLifecycle);
                _applicationAlterations.Each(x => x(_application));

                _binding = _application.Services.GetInstance <BindingRegistry>();
                _bindingRegistrations.Each(x => x(_binding));

                configureApplication(_application, _binding);

                _contextualProviders = _runtime.Factory.GetAll <IContextualInfoProvider>();


                _runtime.Facility.Register(typeof(IApplicationUnderTest), ObjectDef.ForValue(_application));
                _runtime.Facility.Register(typeof(IRemoteSubsystems), ObjectDef.ForValue(this));
            }));
        }
        protected override IWebDriver constructDriver()
        {
            var fileSystem = new FileSystem();
            var settings   = StoryTellerEnvironment.Get <SerenityEnvironment>();

            return(fileSystem.FileExists(settings.WorkingDir, File)
                ? new ChromeDriver(settings.WorkingDir)
                : new ChromeDriver());
        }
        protected override IWebDriver constructDriver()
        {
            var fileSystem = new FileSystem();
            var settings   = StoryTellerEnvironment.Get <SerenityEnvironment>();

            if (fileSystem.FileExists(settings.WorkingDir, File))
            {
                return(new PhantomJSDriver(settings.WorkingDir));
            }

            return(new PhantomJSDriver(AppDomain.CurrentDomain.BaseDirectory));
        }
        public override bool Execute(StoryTellerInput input)
        {
            StoryTellerEnvironment.Set(new SerenityEnvironment
            {
                Browser    = input.BrowserFlag,
                WorkingDir = AppDomain.CurrentDomain.BaseDirectory
            });

            Console.WriteLine("Using browser " + input.BrowserFlag);

            var runner = new ProjectRunner(new[] { Project.LoadFromFile(input.ProjectFile) }, input.ResultsFile);

            if (input.WorkspaceFlag.IsNotEmpty())
            {
                Console.WriteLine("Using workspace " + input.WorkspaceFlag);
                runner.Workspace = input.WorkspaceFlag;
            }

            return(runner.Execute() == 0);
        }
        protected EmbeddedBrowserLifecycle()
        {
            var settings = StoryTellerEnvironment.Get <SerenityEnvironment>();

            _extractor = new EmbeddedDriverExtractor <TEmbeddedDriver>(settings, new FileSystem());
        }