Esempio n. 1
0
        /// <summary>
        /// Initializes the browser.
        /// </summary>
        /// <param name="objectContainer">The object container.</param>
        /// <returns>The browser.</returns>
        public static IBrowser InitializeBrowser(IObjectContainer objectContainer)
        {
            var scenarioContext = objectContainer.Resolve <IContextManager>().ScenarioContext;

            bool reusingBrowser = true;

            if (!browserFactory.Configuration.ReuseBrowser || browser == null || browser.IsDisposed)
            {
                browser = browserFactory.GetBrowser();
                scenarioContext.Set(browser, "CurrentBrowser");
                reusingBrowser = false;
            }

            if (browserFactory.Configuration.EnsureCleanSession)
            {
                browser.ClearCookies();

                if (reusingBrowser)
                {
                    browser.ClearUrl();
                }
            }

            IPageMapper pageMapper = objectContainer.Resolve <IPageMapper>();

            if (pageMapper.MapCount == 0)
            {
                pageMapper.Initialize(browser.BasePageType);
            }

            return(browser);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes the page mapper at the start of the test run.
        /// </summary>
        public void InitializeDriver()
        {
            this.objectContainer.RegisterTypeAs <ProxyLogger, ILogger>();
            var logger = this.objectContainer.Resolve <ILogger>();

            var factory       = BrowserFactory.GetBrowserFactory(logger);
            var configSection = configurationHandler.Value;

            bool reusingBrowser = true;

            if (!configSection.BrowserFactory.ReuseBrowser || browser == null || browser.IsDisposed)
            {
                browser        = factory.GetBrowser();
                reusingBrowser = false;
            }

            if (configSection.BrowserFactory.EnsureCleanSession)
            {
                browser.ClearCookies();

                if (reusingBrowser)
                {
                    browser.ClearUrl();
                }
            }

            // NOTE: Don't register the browser to dispose, since doing so breaks the reuseBrowser support.
            // We will dispose it after scenario or test run as appropriate.
            this.objectContainer.RegisterInstanceAs(browser, dispose: false);

            this.objectContainer.RegisterInstanceAs <ISettingHelper>(new WrappedSettingHelper());

            var mapper = new PageMapper();

            mapper.Initialize(browser.BasePageType);
            this.objectContainer.RegisterInstanceAs <IPageMapper>(mapper);

            this.objectContainer.RegisterTypeAs <ScenarioContextHelper, IScenarioContextHelper>();
            this.objectContainer.RegisterTypeAs <TokenManager, ITokenManager>();

            var repository = new ActionRepository(this.objectContainer);

            this.objectContainer.RegisterInstanceAs <IActionRepository>(repository);
            this.objectContainer.RegisterTypeAs <ActionPipelineService, IActionPipelineService>();

            // Initialize the repository
            repository.Initialize();
        }
Esempio n. 3
0
        public void InitializeDriver()
        {
            this.objectContainer.RegisterTypeAs <ProxyLogger, ILogger>();
            var logger = this.objectContainer.Resolve <ILogger>();

            var factory       = BrowserFactory.GetBrowserFactory(logger);
            var configSection = configurationHandler.Value;

            if (!configSection.BrowserFactory.ReuseBrowser || browser == null)
            {
                browser = factory.GetBrowser();
            }

            if (configSection.BrowserFactory.EnsureCleanSession)
            {
                browser.ClearCookies();
            }

            this.objectContainer.RegisterInstanceAs(browser, dispose: true);

            this.objectContainer.RegisterInstanceAs <ISettingHelper>(new WrappedSettingHelper());

            var mapper = new PageMapper();

            mapper.Initialize(browser.BasePageType);
            this.objectContainer.RegisterInstanceAs <IPageMapper>(mapper);

            this.objectContainer.RegisterTypeAs <ScenarioContextHelper, IScenarioContextHelper>();
            this.objectContainer.RegisterTypeAs <TokenManager, ITokenManager>();

            var repository = new ActionRepository(this.objectContainer);

            this.objectContainer.RegisterInstanceAs <IActionRepository>(repository);
            this.objectContainer.RegisterTypeAs <ActionPipelineService, IActionPipelineService>();

            // Initialize the repository
            repository.Initialize();
        }