コード例 #1
0
        private string FindKeys(SeleniumCommandModel sender)
        {
            var teclas = new StringBuilder();

            if (sender.Value.ContainsText("${KEY_ENTER}"))
            {
                teclas.Append(Keys.Enter);
            }

            return(teclas.ToString());
        }
コード例 #2
0
ファイル: Command.cs プロジェクト: glaysons/SeleniumParser
        private StringBuilder CreateMessage(SeleniumCommandModel sender)
        {
            var message = new StringBuilder();

            message.Append("Could not find component: ");
            message.Append(sender.Targets.FirstOrDefault());

            if (!string.IsNullOrEmpty(sender.Comment))
            {
                message.AppendLine();
                message.Append(sender.Comment);
            }

            return(message);
        }
コード例 #3
0
ファイル: Command.cs プロジェクト: glaysons/SeleniumParser
        protected IWebElement SearchElement(SeleniumCommandModel sender)
        {
            foreach (var target in sender.Targets)
            {
                if (TryGetTargetElement(target, out IWebElement element) && (element != null))
                {
                    return(element);
                }
            }

            if (!string.IsNullOrEmpty(sender.Target))
            {
                var target = CreateTarget(sender.Target);
                if ((target != null) && TryGetTargetElement(target, out IWebElement element) && (element != null))
                {
                    return(element);
                }
            }

            var message = CreateMessage(sender);

            throw new Exception(message.ToString());
        }
コード例 #4
0
        public override void Perform(SeleniumSideModel tests, SeleniumTestModel test, SeleniumCommandModel comand)
        {
            var element = SearchElement(comand);

            element
            .Should()
            .NotBeNull();

            var preventDefault = false;

            var customEvent = GetCustomEvent <SendKeysCommandDelegate>();

            var value = FindKeys(comand);

            customEvent?.Invoke(tests, test, comand, element, ref value, ref preventDefault);

            if (!preventDefault)
            {
                element.SendKeys(value);
            }
        }
コード例 #5
0
        public override void Perform(SeleniumSideModel tests, SeleniumTestModel test, SeleniumCommandModel comand)
        {
            var element = SearchElement(comand);

            element
            .Should()
            .NotBeNull();

            element.Clear();
        }
コード例 #6
0
 public override void Perform(SeleniumSideModel tests, SeleniumTestModel test, SeleniumCommandModel comand)
 {
     Current.Driver.Close();
 }
コード例 #7
0
        public override void Perform(SeleniumSideModel tests, SeleniumTestModel test, SeleniumCommandModel comand)
        {
            var size = comand.Target.Split('x');

            if (size.Length > 1)
            {
                Current.Driver.Manage().Window.Size = new Size(size[0].ToInt(), size[1].ToInt());
            }
        }
コード例 #8
0
ファイル: Command.cs プロジェクト: glaysons/SeleniumParser
 public abstract void Perform(SeleniumSideModel tests, SeleniumTestModel test, SeleniumCommandModel comand);
コード例 #9
0
        public override void Perform(SeleniumSideModel tests, SeleniumTestModel test, SeleniumCommandModel comand)
        {
            var alert = Current.Driver.SwitchTo().Alert();

            alert
            .Should()
            .NotBeNull();

            Current.LastAlert = alert.Text;

            alert.Dismiss();
        }
コード例 #10
0
 public override void Perform(SeleniumSideModel tests, SeleniumTestModel test, SeleniumCommandModel comand)
 {
 }
コード例 #11
0
        public override void Perform(SeleniumSideModel tests, SeleniumTestModel test, SeleniumCommandModel comand)
        {
            Wait(1000 * 2);

            if (!comand.Target.ContainsText("="))
            {
                return;
            }

            var index = comand.Target.Split('=')[1].ToInt();

            Current.Driver.SwitchTo().Frame(frameIndex: index);
        }
コード例 #12
0
        public override void Perform(SeleniumSideModel tests, SeleniumTestModel test, SeleniumCommandModel comand)
        {
            var element = SearchElement(comand);

            element
            .Should()
            .NotBeNull();

            var preventDefault = false;

            var customEvent = GetCustomEvent <DoubleClickCommandDelegate>();

            customEvent?.Invoke(tests, test, comand, element, ref preventDefault);

            if (!preventDefault)
            {
                Current.Actions.DoubleClick(element).Perform();
            }
        }
コード例 #13
0
        private void PerformCommand(SeleniumSideModel tests, Context context, SeleniumTestModel test, SeleniumCommandModel command)
        {
            var current = CommandFactory.Create(context, command.Command);

            if (!(current is INextCommand))
            {
                current.Perform(tests, test, command);
            }
            if (context.LastCommand is INextCommand)
            {
                context.LastCommand.Perform(tests, test, command);
            }
            context.LastCommand = current;
        }
コード例 #14
0
        public override void Perform(SeleniumSideModel tests, SeleniumTestModel test, SeleniumCommandModel comand)
        {
            Current.LastAlert
            .Should()
            .NotBeNull();

            Current.LastAlert
            .Should()
            .Be(comand.Target);
        }
コード例 #15
0
        public override void Perform(SeleniumSideModel tests, SeleniumTestModel test, SeleniumCommandModel comand)
        {
            var element = SearchElement(comand);

            element
            .Should()
            .NotBeNull();

            Current.Actions.MoveToElement(element).Perform();
        }
コード例 #16
0
 public override void Perform(SeleniumSideModel tests, SeleniumTestModel test, SeleniumCommandModel comand)
 {
     Current.Driver.Navigate().GoToUrl(tests.Url + comand.Target);
 }