Esempio n. 1
0
 public void SetPropertyWithExistingKeyShouldOverwriteExistingValue()
 {
     WebTestContext.Set("a", "standard value");
     Assert.True(WebTestContext.Get <string>("a").Equals("standard value"), "Value should have persisted");
     WebTestContext.Set("a", "default value");
     Assert.True(WebTestContext.Get <string>("a").Equals("default value"), "Value should have been overwritten");
 }
 public virtual void TestSetup()
 {
     //Start driver service
     DriverService.Start(this.TestEnvironmentParameters);
     //Merge user provided options to existing default capabilities.
     Capabilities.MergeCapabilities(RunParameterUpdater);
     // Write Runsettings to log file
     TestLogs.WriteLogSection("Original Test Run Parameters", () => TestLogs.Write(this.TestEnvironmentParameters.ToString()));
     WebDriver.Initialize(Capabilities);
     //Write device configuration to log file
     TestLogs.WriteLogSection("DUT Configuration", () => TestLogs.Write(WebDriver.Instance.Capabilities.ToString()));
     WebTestContext.Set(Constants.TestEnvironmentKey, TestEnvironmentParameters);
     TestLogs.AddSection($"Test {TestContext.CurrentContext.Test.Name} Starts");
 }
        private static void SetupScreenshotFileName()
        {
            string testScreenshotFullPath = Path.Combine(screenshotFolder, TestContext.CurrentContext.Test.Name + ".jpeg");

            if (File.Exists(testScreenshotFullPath))
            {
                try {
                    File.Delete(testScreenshotFullPath);
                } catch (UnauthorizedAccessException e) {
                    Console.WriteLine("Cannot cleanup test screenshot file", e);
                } catch (Exception ex) {
                    Console.WriteLine("Cannot cleanup test screenshot file", ex);
                }
            }
            WebTestContext.Set(Constants.ScreenshotFileKey, Path.Combine(screenshotFolder, TestContext.CurrentContext.Test.Name + ".jpeg"));
        }
        private static void SetupTestLog()
        {
            string testFileNameFullPath = Path.Combine(testLogFolder, TestContext.CurrentContext.Test.Name + ".log");

            if (File.Exists(testFileNameFullPath))
            {
                try {
                    File.Delete(testFileNameFullPath);
                } catch (Exception e) {
                    Console.WriteLine($"Cannot cleanup the log file: {e}");
                }
            }

            File.Create(testFileNameFullPath).Close();

            WebTestContext.Set(Constants.TestLogFileKey, testFileNameFullPath);
        }
Esempio n. 5
0
        /// <summary>
        /// Start browser specific driver service
        /// </summary>
        /// <param name="parameters"><see cref="TestEnvironmentParameters"/></param>
        private static void StartBrowserService(TestEnvironmentParameters parameters)
        {
            OpenQA.Selenium.DriverService service;

            switch (parameters.RS_BrowserName.ToUpper())
            {
            case "CHROME":
                service          = ChromeDriverService.CreateDefaultService(parameters.RS_DriverServerExePath);
                service.HostName = parameters.RS_ServerHost;
                service.Port     = Convert.ToInt32(parameters.RS_ServerPort);

                Get(() => service.Start(), "Chrome");
                break;

            case "IE":
                service          = InternetExplorerDriverService.CreateDefaultService(parameters.RS_DriverServerExePath);
                service.HostName = parameters.RS_ServerHost;
                service.Port     = Convert.ToInt32(parameters.RS_ServerPort);
                Get(() => service.Start(), "ie");
                break;

            case "EDGE":
                service          = EdgeDriverService.CreateDefaultService(parameters.RS_DriverServerExePath);
                service.HostName = parameters.RS_ServerHost;
                service.Port     = Convert.ToInt32(parameters.RS_ServerPort);
                Get(() => service.Start(), "Edge");
                break;

            case "SAFARI":
                service          = SafariDriverService.CreateDefaultService(parameters.RS_DriverServerExePath);
                service.HostName = parameters.RS_ServerHost;
                service.Port     = Convert.ToInt32(parameters.RS_ServerPort);
                Get(() => service.Start(), "Safari");
                break;

            default:
                throw new DriverServiceException($"Driver for {parameters.RS_BrowserName} not supported.");
            }

            WebTestContext.Set(Constants.DriverServiceKey, service);
            parameters.ServerUri = service.ServiceUrl;
        }
Esempio n. 6
0
 public void ContainsPassesForValueSavedInContext()
 {
     WebTestContext.Set("a", "SetPropertyWithNewKey");
     Assert.True(WebTestContext.ContainsKey("a"), "Key exists, must return true.");
 }
Esempio n. 7
0
 public void SetPropertyWithNonExistentKeyThrows()
 {
     WebTestContext.Set("a", "SetPropertyWithNewKey");
     Assert.Throws <KeyNotFoundException>(() => WebTestContext.Get <string>("b"), "Key does not exist, should have thrown");
 }
Esempio n. 8
0
 public void SetPropertyWithNewKeyPasses()
 {
     WebTestContext.Set("a", "SetPropertyWithNewKey");
     Assert.True(WebTestContext.Get <string>("a").Equals("SetPropertyWithNewKey"), "Value should have persisted");
 }
 public void TestSetup()
 {
     WebTestContext.Set(nameof(Constants.DevelopmentMode), "true");
 }