Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandManager"/> class.
 /// </summary>
 /// <param name="automationProvider">The automation provider.</param>
 public CommandManager(AutomationProvider automationProvider)
 {
     Provider = automationProvider;
     _actionBuckets.Add(new ActionBucket(this));
     this.RemoteCommands = new List<RemoteCommands.RemoteCommandDetails>();
     this.RemoteBrowsers = new List<BrowserType>();
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpectManager"/> class.
 /// </summary>
 /// <param name="automation">The automation.</param>
 public ExpectManager(AutomationProvider automation, CommandManager manager)
 {
     Provider = automation;
     Manager = manager;
 }
Пример #3
0
 public CommandBase(AutomationProvider provider, CommandManager manager)
 {
     Provider = provider;
     CommandManager = manager;
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Count"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="count">The count.</param>
 public Count(AutomationProvider provider, CommandManager manager, int count)
     : base(provider, manager)
 {
     _count = count;
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DragDrop"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="fieldSelector">The field selector.</param>
 public DragDrop(AutomationProvider provider, CommandManager manager, string fieldSelector)
     : base(provider, manager)
 {
     _dragFieldSelector = fieldSelector;
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CssClass"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="value">The value.</param>
 public CssClass(AutomationProvider provider, CommandManager manager, string value)
     : base(provider, manager)
 {
     _value = value;
 }
Пример #7
0
 /// <summary>
 /// Prevents a default instance of the <see cref="Text"/> class from being created.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="expectType">Type of the expect.</param>
 private Text(AutomationProvider provider, CommandManager manager, ExpectType expectType)
     : base(provider, manager)
 {
     _expectType = expectType;
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Select"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="optionMatchingFunc">The option matching func.</param>
 /// <param name="selectMode">The select mode.</param>
 public Select(AutomationProvider provider, CommandManager manager, Expression<Func<string, bool>> optionMatchingFunc, SelectMode selectMode)
     : base(provider, manager)
 {
     _optionMatchingFunc = optionMatchingFunc;
     _selectMode = selectMode;
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Text"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="expression">The expression.</param>
 public Text(AutomationProvider provider, CommandManager manager, Expression<Func<string, bool>> expression)
     : this(provider, manager, ExpectType.Single)
 {
     _expectedTextExpression = expression;
     _expectedTextFunc = _expectedTextExpression.Compile();
 }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Text"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="text">The text.</param>
 public Text(AutomationProvider provider, CommandManager manager, string text)
     : this(provider, manager, ExpectType.Single)
 {
     _expectedText = text;
 }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Value"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="values">The values.</param>
 /// <param name="requireAll">if set to <c>true</c> [require all].</param>
 public Value(AutomationProvider provider, CommandManager manager, IEnumerable<string> values, bool requireAll)
     : this(provider, manager, ExpectType.All)
 {
     _values = values;
 }
Пример #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Value"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="value">The value.</param>
 public Value(AutomationProvider provider, CommandManager manager, Expression<Func<string, bool>> value)
     : this(provider, manager, ExpectType.Single)
 {
     _valueExpression = value;
     _valueFunc = _valueExpression.Compile();
 }
Пример #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Value"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="value">The value.</param>
 public Value(AutomationProvider provider, CommandManager manager, string value)
     : this(provider, manager, ExpectType.Single)
 {
     _value = value;
 }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Select"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="selectedIndices">The selected indices.</param>
 /// <param name="selectMode">The select mode.</param>
 public Select(AutomationProvider provider, CommandManager manager, int[] selectedIndices, SelectMode selectMode)
     : base(provider, manager)
 {
     _selectedIndices = selectedIndices;
     _selectMode = selectMode;
 }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Select"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="values">The values.</param>
 /// <param name="selectMode">The select mode.</param>
 public Select(AutomationProvider provider, CommandManager manager, string[] values, SelectMode selectMode)
     : base(provider, manager)
 {
     _values = values;
     _selectMode = selectMode;
 }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Element"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="elementExpression">The element expression.</param>
 public Element(AutomationProvider provider, CommandManager manager, Expression<Func<IElementDetails, bool>> elementExpression)
     : base(provider, manager)
 {
     _elementExpression = elementExpression;
 }
        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();
            }
        }
Пример #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Text"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="strings">The strings.</param>
 /// <param name="requireAll">if set to <c>true</c> [require all].</param>
 public Text(AutomationProvider provider, CommandManager manager, IEnumerable<string> strings, bool requireAll)
     : this(provider, manager, ExpectType.All)
 {
     _expectedStrings = strings;
 }