Beispiel #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>();
            }
        }
Beispiel #2
0
        public void Execute(CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (OpenArguments)arguments;
            Guard.ArgumentNotNullForCommand<ExpectValue>(args.Url);

            manager.Open(args.Url);
        }
Beispiel #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);
            }
        }
Beispiel #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);
                }
            }
        }
Beispiel #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>();
            }
        }
        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);
            }
        }
Beispiel #7
0
        public void Execute(API.CommandManager manager, IRemoteCommandArguments arguments)
        {
            var args = (PressArguments)arguments;

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

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

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

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

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

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

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

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

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

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

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

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

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

            manager.Open(args.Url);
        }
        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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
        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);
        }
        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);
        }
Beispiel #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);
        }
Beispiel #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();
            }
        }
        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();
            }
        }
Beispiel #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>();
                }
            }
        }
Beispiel #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>();
                }
            }
        }
Beispiel #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>();
                }
            }
        }
        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>();
                }
            }
        }
Beispiel #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);
            }
        }
        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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
        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);
            }
        }
        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>();
                }
            }
        }
Beispiel #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>();
            }
        }
Beispiel #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>();
            }
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #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();
            }
        }
Beispiel #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();
 }
Beispiel #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);
            }
        }
Beispiel #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();
 }