public static bool IsInvalidAction(IStepAction commandLine)
 {
     return (!DomainConsts.Commands.Contains(commandLine.Command)
         || (commandLine.IsElementDependent &&
         !DomainConsts.FindMethods.Contains(commandLine.FindMethod))
         );
 }
        public void ExecuteElementDependentActionCommand(IStepAction action, IWebElement element)
        {
            _actualAction = action;

            if (_actualAction.IsParameterized)
                ExecuteCommandDependentOfElementParameterized(element);
            else
                ExecuteCommandDependentOfElementNotParameterized(element);
        }
Пример #3
0
        public async Task Execute_WhenGherkinParseResultIsInCacheWithStepActionButAborted_DoesNotCallParserDoesNotAddDependencies()
        {
            //Arrange
            ProviderResult providerResult = new ProviderResult();

            IEnumerable <ProviderSourceDataset> datasets = new[]
            {
                new ProviderSourceDataset()
            };

            IEnumerable <TestScenario> testScenarios = new[]
            {
                new TestScenario
                {
                    Id = "scenario-1"
                }
            };

            BuildProject buildProject = new BuildProject();

            IGherkinParser gherkinParser = CreateGherkinParser();

            GherkinParseResult stepActionherkinParseResult = new GherkinParseResult {
                Abort = true
            };


            IStepAction stepAction = Substitute.For <IStepAction>();

            stepAction
            .Execute(Arg.Is(providerResult), Arg.Is(datasets))
            .Returns(stepActionherkinParseResult);

            GherkinParseResult gherkinParseResult = new GherkinParseResult();

            gherkinParseResult
            .StepActions
            .Add(stepAction);

            string cacheKey = $"{CacheKeys.GherkinParseResult}scenario-1";

            ICacheProvider cacheProvider = CreateCacheProvider();

            cacheProvider
            .GetAsync <GherkinParseResult>(Arg.Is(cacheKey), Arg.Any <JsonSerializerSettings>())
            .Returns(gherkinParseResult);

            GherkinExecutor gherkinExecutor = CreateGherkinExecutor(gherkinParser, cacheProvider);

            //Act
            IEnumerable <ScenarioResult> scenarioResults = await gherkinExecutor.Execute(providerResult, datasets, testScenarios, buildProject);

            //Assert
            await
            gherkinParser
            .DidNotReceive()
            .Parse(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <BuildProject>());

            scenarioResults
            .Count()
            .Should()
            .Be(1);

            scenarioResults
            .First()
            .StepsExecuted
            .Should()
            .Be(0);
        }
Пример #4
0
        public async Task Execute_WhenGherkinParseResultIsNotInCacheWithTeoStepActionAndResultHasError_CreatesResultWithErrors()
        {
            //Arrange
            ProviderResult providerResult = new ProviderResult();

            IEnumerable <ProviderSourceDataset> datasets = new[]
            {
                new ProviderSourceDataset()
            };

            IEnumerable <TestScenario> testScenarios = new[]
            {
                new TestScenario
                {
                    Id      = "scenario-1",
                    Current = new TestScenarioVersion
                    {
                        Gherkin = "gherkin"
                    },
                    SpecificationId = "spec1"
                }
            };

            BuildProject buildProject = new BuildProject();

            GherkinParseResult stepActionherkinParseResult1 = new GherkinParseResult("An error");

            stepActionherkinParseResult1
            .Dependencies
            .Add(new Dependency("ds1", "f1", "value"));

            GherkinParseResult stepActionherkinParseResult2 = new GherkinParseResult();

            stepActionherkinParseResult2
            .Dependencies
            .Add(new Dependency("ds1", "f1", "value"));


            IStepAction stepAction1 = Substitute.For <IStepAction>();

            stepAction1
            .Execute(Arg.Is(providerResult), Arg.Is(datasets))
            .Returns(stepActionherkinParseResult1);

            IStepAction stepAction2 = Substitute.For <IStepAction>();

            stepAction2
            .Execute(Arg.Is(providerResult), Arg.Is(datasets))
            .Returns(stepActionherkinParseResult2);

            GherkinParseResult gherkinParseResult = new GherkinParseResult();

            gherkinParseResult
            .StepActions
            .AddRange(new[] { stepAction1, stepAction2 });

            IGherkinParser gherkinParser = CreateGherkinParser();

            gherkinParser
            .Parse(Arg.Is("spec1"), Arg.Is("gherkin"), Arg.Is(buildProject))
            .Returns(gherkinParseResult);

            string cacheKey = $"{CacheKeys.GherkinParseResult}scenario-1";

            ICacheProvider cacheProvider = CreateCacheProvider();

            cacheProvider
            .GetAsync <GherkinParseResult>(Arg.Is(cacheKey), Arg.Any <JsonSerializerSettings>())
            .Returns((GherkinParseResult)null);

            GherkinExecutor gherkinExecutor = CreateGherkinExecutor(gherkinParser, cacheProvider);

            //Act
            IEnumerable <ScenarioResult> scenarioResults = await gherkinExecutor.Execute(providerResult, datasets, testScenarios, buildProject);

            //Assert
            scenarioResults
            .Count()
            .Should()
            .Be(1);

            scenarioResults
            .First()
            .Dependencies
            .Count()
            .Should()
            .Be(2);

            scenarioResults
            .First()
            .HasErrors
            .Should()
            .BeTrue();

            scenarioResults
            .First()
            .StepsExecuted
            .Should()
            .Be(2);
        }
        public string ExecuteNonElementDependentReadingAction(IStepAction action)
        {
            _actualAction = action;

            return GetPopupJSAlertGetText();
        }
        public void ExecuteNonElementDependentAction(IStepAction action)
        {
            _actualAction = action;

            ExecuteCommandNotDependentOfElement();
        }
        public string ExecuteElementDependentReadingAction(IStepAction action, IWebElement element)
        {
            _actualAction = action;

            return _actualAction.IsParameterized ? GetElementAttributeOrCssValue(element) : TryGetOneElementProperty(element);
        }
 private void SaveActionAndElement(IStepAction action, IWebElement element)
 {
     _lastAction = action;
     _lastElement = element;
 }
        public IWebElement GetElement(IStepAction action)
        {
            _actualAction = action;

            IWebElement element = CanReuseLastElement() ? _lastElement : TryToFindElement(TryBy());

            SaveActionAndElement(_actualAction, element);

            return element;
        }