예제 #1
0
        public WebTestHelper(
            [NotNull] IBrowserConfiguration browserConfiguration,
            [NotNull] ICoypuConfiguration coypuConfiguration,
            [NotNull] IWebTestConfiguration webTestConfiguration)
        {
            ArgumentUtility.CheckNotNull("browserConfiguration", browserConfiguration);
            ArgumentUtility.CheckNotNull("coypuConfiguration", coypuConfiguration);
            ArgumentUtility.CheckNotNull("webTestConfiguration", webTestConfiguration);

            _browserConfiguration = browserConfiguration;
            _coypuConfiguration   = coypuConfiguration;
            _webTestConfiguration = webTestConfiguration;
        }
예제 #2
0
        /// <summary>
        /// Creates a Coypu <see cref="BrowserSession"/> using the configuration given by <paramref name="browserConfiguration"/>.
        /// </summary>
        /// <param name="browserConfiguration">The browser configuration to use.</param>
        /// /// <param name="coypuConfiguration">The Coypu configuration to use.</param>
        /// <returns>A new Coypu <see cref="BrowserSession"/>.</returns>
        public static BrowserSession CreateBrowser(
            [NotNull] IBrowserConfiguration browserConfiguration,
            [NotNull] ICoypuConfiguration coypuConfiguration)
        {
            ArgumentUtility.CheckNotNull("browserConfiguration", browserConfiguration);
            ArgumentUtility.CheckNotNull("coypuConfiguration", coypuConfiguration);

            var sessionConfiguration = new SessionConfiguration
            {
                Browser                   = browserConfiguration.Browser,
                RetryInterval             = coypuConfiguration.RetryInterval,
                Timeout                   = coypuConfiguration.SearchTimeout,
                ConsiderInvisibleElements = WebTestingConstants.ShouldConsiderInvisibleElements,
                Match         = WebTestingConstants.DefaultMatchStrategy,
                TextPrecision = WebTestingConstants.DefaultTextPrecision
            };

            if (sessionConfiguration.Browser == Browser.Chrome)
            {
                // Todo RM-6337: Switch back to always using the default Chrome driver as soon as the ActaNova language problem has been solved.
                if (ConfigurationManager.AppSettings["CustomChromeUserDataDir"] != null)
                {
                    sessionConfiguration.Driver = typeof(CustomChromeDriver);
                    return(new BrowserSession(sessionConfiguration, new CustomChromeDriver()));
                }

                sessionConfiguration.Driver = typeof(SeleniumWebDriver);
                return(new BrowserSession(sessionConfiguration));
            }

            if (sessionConfiguration.Browser == Browser.InternetExplorer)
            {
                sessionConfiguration.Driver = typeof(CustomInternetExplorerDriver);
                return(new BrowserSession(sessionConfiguration, new CustomInternetExplorerDriver()));
            }

            throw new NotSupportedException(string.Format("Only browsers '{0}' and '{1}' are supported.", Browser.Chrome, Browser.InternetExplorer));
        }