/// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 /// <param name="disposing"></param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         DriverOptionsFactory?.Dispose();
     }
 }
Exemple #2
0
        public void SetUp()
        {
#if DEBUG
            AtataContext.Configure()
            .UseDriver(_driverAlias)
            .UseBaseUrl("https://localhost:44345/")
            .Build();
            AtataContext.Current.Driver.Maximize();
#elif DEV
            AtataContext.Configure()
            .UseDriver(_driverAlias)
            .UseBaseUrl("https://svea-webpay-sdk-001-dev.azurewebsites.net/")
            .Build();
            AtataContext.Current.Driver.Maximize();
#elif RELEASE
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json")
                         .AddEnvironmentVariables()
                         .Build();

            AtataContext.Configure()
            .UseChrome()
            .WithOptions(DriverOptionsFactory.GetDriverOptions(Driver.Chrome) as ChromeOptions)
            .UseBaseUrl(config.GetSection("SampleWebsite").GetSection("Url").Value)
            .Build();
            AtataContext.Current.Driver.Maximize();
#endif
        }
        /// <summary>
        /// Return a local WebDriver of the given browser type with default settings.
        /// </summary>
        /// <param name="browser"></param>
        /// <param name="windowSize"></param>
        /// <param name="headless"></param>
        /// <param name="windowCustomSize"></param>
        /// <returns></returns>
        public virtual IWebDriver GetWebDriver(Browser browser, WindowSize windowSize = WindowSize.Hd, bool headless = false, Size windowCustomSize = new Size())
        {
            if (headless &&
                !(browser == Browser.Chrome ||
                  browser == Browser.Edge ||
                  browser == Browser.Firefox))
            {
                Exception ex = new ArgumentException($"Headless mode is not currently supported for {browser}.");
                Logger.Fatal("Invalid WebDriver Configuration requested.", ex);
                throw ex;
            }

            switch (browser)
            {
            case Browser.Firefox:
                return(GetWebDriver(DriverOptionsFactory.GetLocalDriverOptions <FirefoxOptions>(headless), windowSize, windowCustomSize));

            case Browser.Chrome:
                return(GetWebDriver(DriverOptionsFactory.GetLocalDriverOptions <ChromeOptions>(headless), windowSize, windowCustomSize));

            case Browser.InternetExplorer:
                return(GetWebDriver(DriverOptionsFactory.GetLocalDriverOptions <InternetExplorerOptions>(), windowSize, windowCustomSize));

            case Browser.Edge:
                return(GetWebDriver(DriverOptionsFactory.GetLocalDriverOptions <EdgeOptions>(headless), windowSize, windowCustomSize));

            case Browser.Safari:
                return(GetWebDriver(DriverOptionsFactory.GetLocalDriverOptions <SafariOptions>(), windowSize, windowCustomSize));

            default:
                Exception ex = new PlatformNotSupportedException($"{browser} is not currently supported.");
                Logger.Fatal("Invalid WebDriver Configuration requested.", ex);
                throw ex;
            }
        }
Exemple #4
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 /// <param name="disposing"></param>
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         DriverOptionsFactory?.Dispose();
     }
 }
        public void SetUp()
        {
            this.testWebApplicationFactory = new TestWebApplicationFactory();
            var chromeOptions = DriverOptionsFactory.GetDriverOptions(Driver.Chrome) as ChromeOptions;

            AtataContext.Configure()
            .UseChrome()
            .WithOptions(chromeOptions)
            .UseBaseUrl(this.testWebApplicationFactory.RootUri)
            .Build();
        }
 public void OneTimeSetUp()
 {
     AtataContext.GlobalConfiguration.
     UseChrome().
     WithOptions(DriverOptionsFactory.GetDriverOptions(Driver.Chrome) as ChromeOptions).
     UseFirefox().
     WithOptions(DriverOptionsFactory.GetDriverOptions(Driver.Firefox) as FirefoxOptions).
     UseInternetExplorer().
     WithOptions(DriverOptionsFactory.GetDriverOptions(Driver.InternetExplorer) as InternetExplorerOptions).
     AddNUnitTestContextLogging().
     WithMinLevel(LogLevel.Error).
     UseBaseRetryTimeout(TimeSpan.FromSeconds(20));
 }
Exemple #7
0
        public void GlobalSetup()
        {
#if DEBUG
            AtataContext.GlobalConfiguration.
            UseChrome().
            WithOptions(DriverOptionsFactory.GetDriverOptions(Driver.Chrome) as ChromeOptions).
            UseFirefox().
            WithOptions(DriverOptionsFactory.GetDriverOptions(Driver.Firefox) as FirefoxOptions).
            UseVerificationTimeout(TimeSpan.FromSeconds(3)).
            UseElementFindTimeout(TimeSpan.FromSeconds(15)).
            UseWaitingTimeout(TimeSpan.FromSeconds(30)).
            AddNUnitTestContextLogging().
            WithMinLevel(LogLevel.Trace).
            TakeScreenshotOnNUnitError().
            AddScreenshotFileSaving().
            WithFolderPath(() => $@"Logs\{AtataContext.BuildStart:yyyy-MM-dd HH_mm_ss}").
            WithFileName(screenshotInfo => $"{AtataContext.Current.TestName} - {screenshotInfo.PageObjectFullName}").
            UseTestName(() => $"[{_driverAlias}]{TestContext.CurrentContext.Test.Name}");
#endif
        }