예제 #1
0
        public void Execute(CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ClickArguments)arguments;

            if (args.Selector != null && args.ClickMode != null && args.MatchConditions != null)
            {
                manager.Click(args.Selector, args.ClickMode.Value, args.MatchConditions.Value);
            }
            else if (args.Selector != null && args.ClickMode != null)
            {
                manager.Click(args.Selector, args.ClickMode.Value);
            }
            else if (args.Selector != null && args.Point == null)
            {
                manager.Click(args.Selector);
            }
            else if (args.Selector != null && args.Point != null)
            {
                manager.Click(args.Selector, args.Point);
            }
            else if (args.Point != null)
            {
                manager.Click(args.Point);
            }
            else
            {
                throw new InvalidCommandException<Click>();
            }
        }
예제 #2
0
        public void Execute(CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (OpenArguments)arguments;
            Guard.ArgumentNotNullForCommand<ExpectValue>(args.Url);

            manager.Open(args.Url);
        }
예제 #3
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectValueArguments)arguments;

            Guard.ArgumentNotNullForCommand<ExpectValue>(args.Value, args.ValueExpression);
            Guard.ArgumentNotNullForCommand<ExpectValue>(args.Selector);

            API.ExpectCommands.Value valueExpect = null;
            if (args.Value != null)
            {
                valueExpect = manager.Expect.Value(args.Value);
            }
            else
            {
                valueExpect = manager.Expect.Value(args.ValueExpression);
            }

            if (args.MatchConditions.HasValue)
            {
                valueExpect.In(args.Selector, args.MatchConditions.Value);
            }
            else
            {
                valueExpect.In(args.Selector);
            }
        }
예제 #4
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (EnterArguments)arguments;

            Guard.ArgumentNotNullForCommand <Enter>(args.Value);
            Guard.ArgumentNotNullForCommand <Enter>(args.Selector);

            if (args.Quickly)
            {
                if (args.MatchConditions.HasValue)
                {
                    manager.Enter(args.Value).Quickly.In(args.Selector, args.MatchConditions.Value);
                }
                else
                {
                    manager.Enter(args.Value).Quickly.In(args.Selector);
                }
            }
            else
            {
                if (args.MatchConditions.HasValue)
                {
                    manager.Enter(args.Value).In(args.Selector, args.MatchConditions.Value);
                }
                else
                {
                    manager.Enter(args.Value).In(args.Selector);
                }
            }
        }
예제 #5
0
        public void Execute(CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ClickArguments)arguments;

            if (args.Selector != null && args.ClickMode != null && args.MatchConditions != null)
            {
                manager.Click(args.Selector, args.ClickMode.Value, args.MatchConditions.Value);
            }
            else if (args.Selector != null && args.ClickMode != null)
            {
                manager.Click(args.Selector, args.ClickMode.Value);
            }
            else if (args.Selector != null && args.Point == null)
            {
                manager.Click(args.Selector);
            }
            else if (args.Selector != null && args.Point != null)
            {
                manager.Click(args.Selector, args.Point);
            }
            else if (args.Point != null)
            {
                manager.Click(args.Point);
            }
            else
            {
                throw new InvalidCommandException <Click>();
            }
        }
예제 #6
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectValueArguments)arguments;

            Guard.ArgumentNotNullForCommand <ExpectValue>(args.Value, args.ValueExpression);
            Guard.ArgumentNotNullForCommand <ExpectValue>(args.Selector);

            API.ExpectCommands.Value valueExpect = null;
            if (args.Value != null)
            {
                valueExpect = manager.Expect.Value(args.Value);
            }
            else
            {
                valueExpect = manager.Expect.Value(args.ValueExpression);
            }

            if (args.MatchConditions.HasValue)
            {
                valueExpect.In(args.Selector, args.MatchConditions.Value);
            }
            else
            {
                valueExpect.In(args.Selector);
            }
        }
예제 #7
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (PressArguments)arguments;

            Guard.ArgumentNotNullForCommand <Press>(args.Keys);

            manager.Press(args.Keys);
        }
예제 #8
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (TypeArguments)arguments;

            Guard.ArgumentNotNullForCommand <Type>(args.Value);

            manager.Type(args.Value);
        }
예제 #9
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (NavigateArguments)arguments;

            Guard.ArgumentNotNullForCommand <Navigate>(args.Direction);

            manager.Navigate(args.Direction.Value);
        }
예제 #10
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (PressArguments)arguments;

            Guard.ArgumentNotNullForCommand<Press>(args.Keys);

            manager.Press(args.Keys);
        }
예제 #11
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (NavigateArguments)arguments;

            Guard.ArgumentNotNullForCommand<Navigate>(args.Direction);

            manager.Navigate(args.Direction.Value);
        }
예제 #12
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (TypeArguments)arguments;

            Guard.ArgumentNotNullForCommand<Type>(args.Value);

            manager.Type(args.Value);
        }
예제 #13
0
        public void Execute(CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (OpenArguments)arguments;

            Guard.ArgumentNotNullForCommand <ExpectValue>(args.Url);

            manager.Open(args.Url);
        }
예제 #14
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ScreenshotArguments)arguments;

            Guard.ArgumentNotNullForCommand <Screenshot>(args.FileName);

            // TODO: Save this somewhere accessible..
            manager.TakeScreenshot(args.FileName);
        }
예제 #15
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ScreenshotArguments)arguments;

            Guard.ArgumentNotNullForCommand<Screenshot>(args.FileName);

            // TODO: Save this somewhere accessible..
            manager.TakeScreenshot(args.FileName);
        }
예제 #16
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (DragArguments)arguments;

            Guard.ArgumentNotNullForCommand <Drag>(args.From);
            Guard.ArgumentNotNullForCommand <Drag>(args.To);

            manager.Drag(args.From).To(args.To);
        }
예제 #17
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectElementArguments)arguments;

            Guard.ArgumentNotNullForCommand <ExpectClass>(args.Selector);
            Guard.ArgumentNotNullForCommand <ExpectClass>(args.Expression);

            manager.Expect.Element(args.Expression).In(args.Selector);
        }
예제 #18
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectElementArguments)arguments;

            Guard.ArgumentNotNullForCommand<ExpectClass>(args.Selector);
            Guard.ArgumentNotNullForCommand<ExpectClass>(args.Expression);

            manager.Expect.Element(args.Expression).In(args.Selector);
        }
예제 #19
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (DragArguments)arguments;

            Guard.ArgumentNotNullForCommand<Drag>(args.From);
            Guard.ArgumentNotNullForCommand<Drag>(args.To);

            manager.Drag(args.From).To(args.To);
        }
예제 #20
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectAlertArguments)arguments;

            if (args.Text != null)
            {
                manager.Expect.Alert(args.Text);
            }
            else
            {
                manager.Expect.Alert();
            }
        }
예제 #21
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectAlertArguments)arguments;

            if (args.Text != null)
            {
                manager.Expect.Alert(args.Text);
            }
            else
            {
                manager.Expect.Alert();
            }
        }
예제 #22
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectAnyArguments)arguments;

            Guard.ArgumentNotNullForCommand<ExpectAny>(args.Values);

            IValueTextCommand anyExpect = null;

            if (args.SelectMode.HasValue)
            {
                anyExpect = manager.Expect.Any(args.SelectMode.Value, args.Values);
            }
            else
            {
                anyExpect = manager.Expect.Any(args.Values);
            }

            if (args.MatchConditions.HasValue)
            {
                if (args.Selector != null)
                {
                    anyExpect.In(args.Selector, args.MatchConditions.Value);
                }
                else if (args.Selectors != null)
                {
                    Guard.ArgumentExpressionTrueForCommand<ExpectAny>(() => args.Selectors.Length > 0);
                    anyExpect.In(args.MatchConditions.Value, args.Selectors);
                }
                else
                {
                    throw new InvalidCommandException<ExpectAny>();
                }
            }
            else
            {
                if (args.Selector != null)
                {
                    anyExpect.In(args.Selector);
                }
                else if (args.Selectors != null)
                {
                    Guard.ArgumentExpressionTrueForCommand<ExpectAny>(() => args.Selectors.Length > 0);
                    anyExpect.In(args.Selectors);
                }
                else
                {
                    throw new InvalidCommandException<ExpectAny>();
                }
            }
        }
예제 #23
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectTextArguments)arguments;

            Guard.ArgumentNotNullForCommand <ExpectText>(args.Value, args.ValueExpression);
            Guard.ArgumentNotNullForCommand <ExpectText>(args.Selector);

            API.ExpectCommands.Text textExpect = null;
            if (args.Value != null)
            {
                textExpect = manager.Expect.Text(args.Value);
            }
            else if (args.ValueExpression != null)
            {
                textExpect = manager.Expect.Text(args.ValueExpression);
            }

            if (args.MatchConditions.HasValue)
            {
                if (args.Selector != null)
                {
                    textExpect.In(args.Selector, args.MatchConditions.Value);
                }
                else if (args.Selectors != null)
                {
                    Guard.ArgumentExpressionTrueForCommand <ExpectText>(() => args.Selectors.Length > 0);
                    textExpect.In(args.MatchConditions.Value, args.Selectors);
                }
                else
                {
                    throw new InvalidCommandException <ExpectText>();
                }
            }
            else
            {
                if (args.Selector != null)
                {
                    textExpect.In(args.Selector);
                }
                else if (args.Selectors != null)
                {
                    Guard.ArgumentExpressionTrueForCommand <ExpectText>(() => args.Selectors.Length > 0);
                    textExpect.In(args.Selectors);
                }
                else
                {
                    throw new InvalidCommandException <ExpectText>();
                }
            }
        }
예제 #24
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectTextArguments)arguments;

            Guard.ArgumentNotNullForCommand<ExpectText>(args.Value, args.ValueExpression);
            Guard.ArgumentNotNullForCommand<ExpectText>(args.Selector);

            API.ExpectCommands.Text textExpect = null;
            if (args.Value != null)
            {
                textExpect = manager.Expect.Text(args.Value);
            }
            else if (args.ValueExpression != null)
            {
                textExpect = manager.Expect.Text(args.ValueExpression);
            }

            if (args.MatchConditions.HasValue)
            {
                if (args.Selector != null)
                {
                    textExpect.In(args.Selector, args.MatchConditions.Value);
                }
                else if (args.Selectors != null)
                {
                    Guard.ArgumentExpressionTrueForCommand<ExpectText>(() => args.Selectors.Length > 0);
                    textExpect.In(args.MatchConditions.Value, args.Selectors);
                }
                else
                {
                    throw new InvalidCommandException<ExpectText>();
                }
            }
            else
            {
                if (args.Selector != null)
                {
                    textExpect.In(args.Selector);
                }
                else if (args.Selectors != null)
                {
                    Guard.ArgumentExpressionTrueForCommand<ExpectText>(() => args.Selectors.Length > 0);
                    textExpect.In(args.Selectors);
                }
                else
                {
                    throw new InvalidCommandException<ExpectText>();
                }
            }
        }
예제 #25
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectAnyArguments)arguments;

            Guard.ArgumentNotNullForCommand <ExpectAny>(args.Values);

            IValueTextCommand anyExpect = null;

            if (args.SelectMode.HasValue)
            {
                anyExpect = manager.Expect.Any(args.SelectMode.Value, args.Values);
            }
            else
            {
                anyExpect = manager.Expect.Any(args.Values);
            }

            if (args.MatchConditions.HasValue)
            {
                if (args.Selector != null)
                {
                    anyExpect.In(args.Selector, args.MatchConditions.Value);
                }
                else if (args.Selectors != null)
                {
                    Guard.ArgumentExpressionTrueForCommand <ExpectAny>(() => args.Selectors.Length > 0);
                    anyExpect.In(args.MatchConditions.Value, args.Selectors);
                }
                else
                {
                    throw new InvalidCommandException <ExpectAny>();
                }
            }
            else
            {
                if (args.Selector != null)
                {
                    anyExpect.In(args.Selector);
                }
                else if (args.Selectors != null)
                {
                    Guard.ArgumentExpressionTrueForCommand <ExpectAny>(() => args.Selectors.Length > 0);
                    anyExpect.In(args.Selectors);
                }
                else
                {
                    throw new InvalidCommandException <ExpectAny>();
                }
            }
        }
예제 #26
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectUrlArguments)arguments;

            Guard.ArgumentNotNullForCommand<ExpectUrl>(args.URL);

            if (args.URLExpression == null)
            {
                manager.Expect.Url(args.URL);
            }
            else
            {
                manager.Expect.Url(args.URLExpression);
            }
        }
예제 #27
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectUrlArguments)arguments;

            Guard.ArgumentNotNullForCommand <ExpectUrl>(args.URL);

            if (args.URLExpression == null)
            {
                manager.Expect.Url(args.URL);
            }
            else
            {
                manager.Expect.Url(args.URLExpression);
            }
        }
예제 #28
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (UploadArguments)arguments;

            Guard.ArgumentNotNullForCommand<Upload>(args.Selector);
            Guard.ArgumentNotNullForCommand<Upload>(args.FileName);

            if (args.Offset == null)
            {
                manager.Upload(args.FileName, args.Selector);
            }
            else
            {
                manager.Upload(args.FileName, args.Selector, args.Offset);
            }
        }
예제 #29
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectNullArguments)arguments;

            Guard.ArgumentNotNullForCommand<ExpectNull>(args.Selector);
            string nullString = null;

            if (args.MatchConditions.HasValue)
            {
                manager.Expect.Value(nullString).In(args.Selector, args.MatchConditions.Value);
            }
            else
            {
                manager.Expect.Value(nullString).In(args.Selector);
            }
        }
예제 #30
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (UploadArguments)arguments;

            Guard.ArgumentNotNullForCommand <Upload>(args.Selector);
            Guard.ArgumentNotNullForCommand <Upload>(args.FileName);

            if (args.Offset == null)
            {
                manager.Upload(args.FileName, args.Selector);
            }
            else
            {
                manager.Upload(args.FileName, args.Selector, args.Offset);
            }
        }
예제 #31
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectCountArguments)arguments;

            Guard.ArgumentNotNullForCommand <ExpectCount>(args.Value);
            Guard.ArgumentNotNullForCommand <ExpectCount>(args.Selector);

            if (args.MatchConditions.HasValue)
            {
                manager.Expect.Count(args.Value).Of(args.Selector, args.MatchConditions.Value);
            }
            else
            {
                manager.Expect.Count(args.Value).Of(args.Selector);
            }
        }
예제 #32
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectNullArguments)arguments;

            Guard.ArgumentNotNullForCommand <ExpectNull>(args.Selector);
            string nullString = null;

            if (args.MatchConditions.HasValue)
            {
                manager.Expect.Value(nullString).In(args.Selector, args.MatchConditions.Value);
            }
            else
            {
                manager.Expect.Value(nullString).In(args.Selector);
            }
        }
예제 #33
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (ExpectClassArguments)arguments;

            Guard.ArgumentNotNullForCommand <ExpectClass>(args.Value);
            Guard.ArgumentNotNullForCommand <ExpectClass>(args.Selector);

            var classExpect = manager.Expect.Class(args.Value);

            if (args.MatchConditions.HasValue)
            {
                classExpect.On(args.Selector);
            }

            if (args.MatchConditions.HasValue)
            {
                if (args.Selector != null)
                {
                    classExpect.On(args.Selector, args.MatchConditions.Value);
                }
                else if (args.Selectors != null)
                {
                    Guard.ArgumentExpressionTrueForCommand <ExpectAny>(() => args.Selectors.Length > 0);
                    classExpect.On(args.Selectors);
                }
                else
                {
                    throw new InvalidCommandException <ExpectAny>();
                }
            }
            else
            {
                if (args.Selector != null)
                {
                    classExpect.On(args.Selector);
                }
                else if (args.Selectors != null)
                {
                    Guard.ArgumentExpressionTrueForCommand <ExpectAny>(() => args.Selectors.Length > 0);
                    classExpect.On(args.Selectors);
                }
                else
                {
                    throw new InvalidCommandException <ExpectAny>();
                }
            }
        }
예제 #34
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (WaitArguments)arguments;

            if (args.Seconds > 0)
            {
                manager.Wait(TimeSpan.FromSeconds(args.Seconds));
            }
            else if (args.Milliseconds > 0)
            {
                manager.Wait(TimeSpan.FromMilliseconds(args.Milliseconds));
            }
            else
            {
                throw new InvalidCommandException<Wait>();
            }
        }
예제 #35
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (WaitArguments)arguments;

            if (args.Seconds > 0)
            {
                manager.Wait(TimeSpan.FromSeconds(args.Seconds));
            }
            else if (args.Milliseconds > 0)
            {
                manager.Wait(TimeSpan.FromMilliseconds(args.Milliseconds));
            }
            else
            {
                throw new InvalidCommandException <Wait>();
            }
        }
예제 #36
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (HoverArguments)arguments;

            Guard.ArgumentNotNullForCommand<Hover>(args.Selector);

            if (args.Point == null)
            {
                if (args.MatchConditions.HasValue)
                {
                    manager.Hover(args.Selector, args.MatchConditions.Value);
                }
                else
                {
                    manager.Hover(args.Selector);
                }
            }
            else
            {
                manager.Hover(args.Point);
            }
        }
예제 #37
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (HoverArguments)arguments;

            Guard.ArgumentNotNullForCommand <Hover>(args.Selector);

            if (args.Point == null)
            {
                if (args.MatchConditions.HasValue)
                {
                    manager.Hover(args.Selector, args.MatchConditions.Value);
                }
                else
                {
                    manager.Hover(args.Selector);
                }
            }
            else
            {
                manager.Hover(args.Point);
            }
        }
예제 #38
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (SelectArguments)arguments;

            Guard.ArgumentNotNullForCommand<Select>(args.Selector);

            API.FieldCommands.Select selectCommand = null;

            if (args.SelectMode.HasValue)
            {
                if (args.Value != null)
                {
                    selectCommand = manager.Select(args.Value, args.SelectMode.Value);
                }
                else if (args.Values != null)
                {
                    selectCommand = manager.Select(args.SelectMode.Value, args.Values.ToArray());
                }
                else if (args.Index != null)
                {
                    selectCommand = manager.Select(args.Index.Value);
                }
                else if (args.Indices != null)
                {
                    selectCommand = manager.Select(args.Indices.ToArray());
                }
                else if (args.ValueExpression != null)
                {
                    selectCommand = manager.Select(args.ValueExpression, args.SelectMode.Value);
                }
                else
                {
                    throw new InvalidCommandException<Select>();
                }
            }
            else
            {
                if (args.Value != null)
                {
                    selectCommand = manager.Select(args.Value);
                }
                else if (args.Values != null)
                {
                    selectCommand = manager.Select(args.Values.ToArray());
                }
                else if (args.Index != null)
                {
                    selectCommand = manager.Select(args.Index.Value);
                }
                else if (args.Indices != null)
                {
                    selectCommand = manager.Select(args.Indices.ToArray());
                }
                else if (args.ValueExpression != null)
                {
                    selectCommand = manager.Select(args.ValueExpression);
                }
                else
                {
                    throw new InvalidCommandException<Select>();
                }
            }

            if (args.MatchConditions.HasValue)
            {
                selectCommand.From(args.Selector, args.MatchConditions.Value);
            }
            else
            {
                selectCommand.From(args.Selector);
            }
        }
        public static TestDetails GetRemoteCommands(IEnumerable <RemoteCommandDetails> commands)
        {
            TestDetails testDetails = new TestDetails();
            Assembly    asm         = typeof(IRemoteCommand).Assembly;

            try
            {
                foreach (var command in commands)
                {
                    // attempt to locate mapper
                    // TODO: Get rid of the 'magic string' Commands part, make this work with loaded assemblies
                    var type = asm.GetType(string.Format("{0}.{1}.{2}", typeof(RemoteCommandManager).Namespace, "Commands", command.Name));
                    if (type == null)
                    {
                        throw new ArgumentException(string.Format("Unable to locate available command: {0}", command.Name));
                    }

                    CommandArgumentsTypeAttribute commandArgs = (CommandArgumentsTypeAttribute)type.GetCustomAttributes(typeof(CommandArgumentsTypeAttribute), false).FirstOrDefault();
                    if (commandArgs == null)
                    {
                        throw new ArgumentException(string.Format("Unable to locate command arguments handler for command: {0}", command.Name));
                    }

                    IRemoteCommand          cmd  = (IRemoteCommand)Activator.CreateInstance(type);
                    IRemoteCommandArguments args = null;
                    try
                    {
                        args = DeserializeArguments(commandArgs.ArgsType, command.Arguments);
                    }
                    catch (Exception ex)
                    {
                        throw new ArgumentException(string.Format("An error occurred while processing the arguments provided for command: {0}", command.Name), ex);
                    }

                    if (cmd.GetType() == typeof(Commands.Use))
                    {
                        var useArgs = (Commands.UseArguments)args;
                        Guard.ArgumentExpressionTrueForCommand <Commands.Use>(() => useArgs.BrowserType.Count > 0);

                        testDetails.Browsers.AddRange(useArgs.BrowserType);
                    }
                    else
                    {
                        testDetails.RemoteCommands.Add(cmd, args);
                    }
                }

                if (testDetails.Browsers.Count == 0)
                {
                    testDetails.Browsers.Add(BrowserType.Chrome);
                }
            }
            catch (FluentAutomation.API.Exceptions.AssertException)
            {
                throw;
            }
            catch (ArgumentException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred while executing the specified commands.", ex);
            }

            return(testDetails);
        }
        public void Execute(AutomationProvider provider, IEnumerable <RemoteCommandDetails> commands)
        {
            CommandManager manager = new CommandManager(provider);
            Assembly       asm     = typeof(RemoteCommandManager).Assembly;

            try
            {
                // force remote execution to false, don't want loops of RemoteCommands!
                manager.EnableRemoteExecution = false;
                manager.Record();

                var browserList = new List <BrowserType>();

                foreach (var command in commands)
                {
                    // attempt to locate mapper
                    // TODO: Get rid of the 'magic string' Commands part, make this work with loaded assemblies
                    var type = asm.GetType(string.Format("{0}.{1}.{2}", typeof(RemoteCommandManager).Namespace, "Commands", command.Name));
                    if (type == null)
                    {
                        throw new ArgumentException(string.Format("Unable to locate available command: {0}", command.Name));
                    }

                    CommandArgumentsTypeAttribute commandArgs = (CommandArgumentsTypeAttribute)type.GetCustomAttributes(typeof(CommandArgumentsTypeAttribute), false).FirstOrDefault();
                    if (commandArgs == null)
                    {
                        provider.Cleanup();
                        throw new ArgumentException(string.Format("Unable to locate command arguments handler for command: {0}", command.Name));
                    }

                    IRemoteCommand cmd = (IRemoteCommand)Activator.CreateInstance(type);

                    IRemoteCommandArguments args = null;
                    try
                    {
                        args = DeserializeArguments(commandArgs.ArgsType, command.Arguments);
                    }
                    catch (Exception ex)
                    {
                        throw new ArgumentException(string.Format("An error occurred while processing the arguments provided for command: {0}", command.Name), ex);
                    }

                    if (cmd.GetType() == typeof(Commands.Use))
                    {
                        var useArgs = (Commands.UseArguments)args;
                        Guard.ArgumentExpressionTrueForCommand <Commands.Use>(() => useArgs.BrowserType.Count > 0);

                        browserList.AddRange(useArgs.BrowserType);
                    }
                    else
                    {
                        cmd.Execute(manager, args);
                    }
                }

                if (browserList.Count == 0)
                {
                    browserList.Add(BrowserType.Chrome);
                }

                manager.Execute(browserList.ToArray());
            }
            catch (FluentAutomation.API.Exceptions.AssertException)
            {
                throw;
            }
            catch (ArgumentException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred while executing the specified commands.", ex);
            }
            finally
            {
                provider.Cleanup();
            }
        }
예제 #41
0
 public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
 {
     // for the JSON-based API, this command is used to send a set of browsers
     // to test in and is not executed directly.
     throw new NotImplementedException();
 }
예제 #42
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (SelectArguments)arguments;

            Guard.ArgumentNotNullForCommand <Select>(args.Selector);

            API.FieldCommands.Select selectCommand = null;

            if (args.SelectMode.HasValue)
            {
                if (args.Value != null)
                {
                    selectCommand = manager.Select(args.Value, args.SelectMode.Value);
                }
                else if (args.Values != null)
                {
                    selectCommand = manager.Select(args.SelectMode.Value, args.Values.ToArray());
                }
                else if (args.Index != null)
                {
                    selectCommand = manager.Select(args.Index.Value);
                }
                else if (args.Indices != null)
                {
                    selectCommand = manager.Select(args.Indices.ToArray());
                }
                else if (args.ValueExpression != null)
                {
                    selectCommand = manager.Select(args.ValueExpression, args.SelectMode.Value);
                }
                else
                {
                    throw new InvalidCommandException <Select>();
                }
            }
            else
            {
                if (args.Value != null)
                {
                    selectCommand = manager.Select(args.Value);
                }
                else if (args.Values != null)
                {
                    selectCommand = manager.Select(args.Values.ToArray());
                }
                else if (args.Index != null)
                {
                    selectCommand = manager.Select(args.Index.Value);
                }
                else if (args.Indices != null)
                {
                    selectCommand = manager.Select(args.Indices.ToArray());
                }
                else if (args.ValueExpression != null)
                {
                    selectCommand = manager.Select(args.ValueExpression);
                }
                else
                {
                    throw new InvalidCommandException <Select>();
                }
            }

            if (args.MatchConditions.HasValue)
            {
                selectCommand.From(args.Selector, args.MatchConditions.Value);
            }
            else
            {
                selectCommand.From(args.Selector);
            }
        }
예제 #43
0
 public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
 {
     // for the JSON-based API, this command is used to send a set of browsers
     // to test in and is not executed directly.
     throw new NotImplementedException();
 }