Ejemplo n.º 1
0
        public void PassingAdditionalOptionsToOverrideRunSettingsServerParamsPasses()
        {
            var context = new TestEnvironmentParameters {
                RS_BrowserName    = "chrome",
                RS_ServerHost     = "someHost",
                RS_ServerPort     = "1234",
                RS_ServerResource = "/abd/def"
            };

            DriverCapabilities  cap     = new DriverCapabilities(context);
            RunParameterUpdater options = new RunParameterUpdater();

            options
            .Update(nameof(Constants.RS_ServerHost), Constants.RS_ServerHost)
            .Update(nameof(Constants.RS_ServerPort), Constants.RS_ServerPort)
            .Update(nameof(Constants.RS_ServerResource), Constants.RS_ServerResource);
            cap.OverrideRunSettingsParams(options);

            Assert.AreEqual(context.RS_ServerHost, Constants.RS_ServerHost, $"{nameof(Constants.RS_ServerHost)} should have been updated.");
            Assert.AreEqual(context.RS_ServerPort, Constants.RS_ServerPort, $"{nameof(Constants.RS_ServerPort)} should have been updated.");
            Assert.AreEqual(context.RS_ServerResource, Constants.RS_ServerResource, $"{nameof(Constants.RS_ServerResource)} should have been updated.");
            context.ServerUri = Helpers.CreateUri(context.RS_ServerHost, context.RS_ServerPort, context.RS_ServerResource);
            Assert.AreEqual(context.ServerUri.Host, Constants.RS_ServerHost, $"{nameof(context.ServerUri.Host)} should have been updated.");
            Assert.AreEqual(context.ServerUri.Port, Convert.ToInt32(Constants.RS_ServerPort), $"{nameof(context.ServerUri.Port)} should have been updated.");
            Assert.AreEqual(context.ServerUri.PathAndQuery, Constants.RS_ServerResource, $"{nameof(context.ServerUri.PathAndQuery)} should have been updated.");
        }
Ejemplo n.º 2
0
        public void PassingAdditionalOptionsToOverrideRunSettingsDriverParamsPasses()
        {
            var context = new TestEnvironmentParameters {
                RS_BrowserName             = "edge",
                RS_DeviceGroup             = "edge;win10",
                RS_DriverServerExePath     = "somePath",
                RS_ImplicitWaitTime        = "100",
                RS_LocalExecution          = true,
                RS_LocalExecutionAsService = true
            };

            DriverCapabilities  cap     = new DriverCapabilities(context);
            RunParameterUpdater options = new RunParameterUpdater();

            options.Update(nameof(Constants.RS_BrowserName), Constants.RS_BrowserName)
            .Update(nameof(Constants.RS_DeviceGroup), Constants.RS_DeviceGroup)
            .Update(nameof(Constants.RS_DriverServerExePath), Constants.RS_DriverServerExePath)
            .Update(nameof(Constants.RS_ImplicitWaitTime), Constants.RS_ImplicitWaitTime)
            .Update(nameof(Constants.RS_LocalExecution), Convert.ToBoolean(Constants.RS_LocalExecution))
            .Update(nameof(Constants.RS_LocalExecutionAsService), Convert.ToBoolean(Constants.RS_LocalExecutionAsService));
            cap.OverrideRunSettingsParams(options);
            Assert.AreEqual(context.RS_BrowserName, Constants.RS_BrowserName, $"{nameof(Constants.RS_BrowserName)} should have been updated.");
            Assert.AreEqual(context.RS_DeviceGroup, Constants.RS_DeviceGroup, $"{nameof(Constants.RS_DeviceGroup)} should have been updated.");
            Assert.AreEqual(context.RS_DriverServerExePath, Constants.RS_DriverServerExePath, $"{nameof(Constants.RS_DriverServerExePath)} should have been updated.");
            Assert.AreEqual(context.RS_ImplicitWaitTime, Constants.RS_ImplicitWaitTime, $"{nameof(Constants.RS_ImplicitWaitTime)} should have been updated.");
            Assert.AreEqual(context.RS_LocalExecution, Convert.ToBoolean(Constants.RS_LocalExecution), $"{nameof(Constants.RS_LocalExecution)} should have been updated.");
            Assert.AreEqual(context.RS_LocalExecutionAsService, Convert.ToBoolean(Constants.RS_LocalExecutionAsService), $"{nameof(Constants.RS_LocalExecutionAsService)} should have been updated.");
        }
Ejemplo n.º 3
0
        public void NullServerHostOnOverridingShouldThrow()
        {
            TestEnvironmentParameters @params = new TestEnvironmentParameters()
            {
                RS_BrowserName = "chrome"
            };
            var cap = new DriverCapabilities(@params);
            RunParameterUpdater opts = new RunParameterUpdater();

            opts.Update(nameof(@params.ServerUri), null);
            Assert.Throws <ArgumentNullException>(() => cap.MergeCapabilities(opts), "Should not be allowed to create instance if host is null or empty");
        }
Ejemplo n.º 4
0
        public void NullBrowserNameOnOverridingShouldThrow()
        {
            TestEnvironmentParameters @params = new TestEnvironmentParameters()
            {
                RS_BrowserName = "chrome"
            };
            var cap = new DriverCapabilities(@params);
            RunParameterUpdater opts = new RunParameterUpdater();

            opts.Update(nameof(Constants.RS_BrowserName), "");
            Assert.Throws <InvalidCapabilityException>(() => cap.MergeCapabilities(opts), "Should not be allowed to create instance if browser name is null or empty");
        }
Ejemplo n.º 5
0
        public void PassingArgumentToChromePasses()
        {
            var context = new TestEnvironmentParameters {
                RS_BrowserName = "Chrome",
                ServerUri      = Helpers.CreateUri("localhost", "1234", "/wd/hub/")
            };
            DriverCapabilities  cap = new DriverCapabilities(context);
            RunParameterUpdater opt = new RunParameterUpdater();
            string argumentToAdd    = "--somerandomStuff";

            cap.GetDriverOptions <ChromeOptions>().AddArgument(argumentToAdd);
            cap.MergeCapabilities(opt);
            Assert.True(cap.GetDriverOptions <ChromeOptions>().Arguments.IndexOf(argumentToAdd) > 0, "Argument should have been added");
        }