Exemple #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>();
 }
        public void TheRootIsTheContainingGrid()
        {
            var expectedGrid = new AutomationProvider();
            _parent.Setup(x => x.FragmentRoot).Returns(expectedGrid);

            CellProvider.ContainingGrid.Should().BeSameAs(expectedGrid);
        }
        public void TheRootIsTheContainingGrid()
        {
            var expectedGrid = new AutomationProvider();

            _parent.Setup(x => x.FragmentRoot).Returns(expectedGrid);

            CellProvider.ContainingGrid.Should().BeSameAs(expectedGrid);
        }
        public HeaderItemProvider(AutomationProvider headerProvider, HeaderInformation header, int index) : base(headerProvider)
        {
            header = header ?? HeaderInformation.NullHeader;

            Index = index;
            Name = header.Text;
            ControlType = ControlType.HeaderItem;

            SetPropertyValue(AutomationElementIdentifiers.IsOffscreenProperty.Id, () => !header.IsVisible);
        }
Exemple #5
0
        public HeaderItemProvider(AutomationProvider headerProvider, HeaderInformation header, int index) : base(headerProvider)
        {
            header = header ?? HeaderInformation.NullHeader;

            Index       = index;
            Name        = header.Text;
            ControlType = ControlType.HeaderItem;

            SetPropertyValue(AutomationElementIdentifiers.IsOffscreenProperty.Id, () => !header.IsVisible);
        }
        public TableRowProvider(AutomationProvider parent, RowInformation rowInformation)
            : base(parent, SelectionItemPattern.Pattern)
        {
            _rowInformation = rowInformation;
            Name = rowInformation.Value;
            ControlType = ControlType.DataItem;

            rowInformation.Cells.ForEach(x => AddChild(new TableCellProvider(this, x)));

            SetPropertyValue(AutomationElementIdentifiers.IsOffscreenProperty.Id, () => !rowInformation.IsVisible);
        }
Exemple #7
0
        public TableRowProvider(AutomationProvider parent, RowInformation rowInformation)
            : base(parent, SelectionItemPattern.Pattern)
        {
            _rowInformation = rowInformation;
            Name            = rowInformation.Value;
            ControlType     = ControlType.DataItem;

            rowInformation.Cells.ForEach(x => AddChild(new TableCellProvider(this, x)));

            SetPropertyValue(AutomationElementIdentifiers.IsOffscreenProperty.Id, () => !rowInformation.IsVisible);
        }
 public HeaderProvider(AutomationProvider automationProvider, IEnumerable<HeaderInformation> headers) : base(automationProvider)
 {
     headers.ForEachWithIndex( (header, index) => AddChild(new HeaderItemProvider(this, header, index)));
     ControlType = ControlType.Header;
 }
Exemple #9
0
 public HeaderProvider(AutomationProvider automationProvider, IEnumerable <HeaderInformation> headers) : base(automationProvider)
 {
     headers.ForEachWithIndex((header, index) => AddChild(new HeaderItemProvider(this, header, index)));
     ControlType = ControlType.Header;
 }
Exemple #10
0
 public TableCellProvider(AutomationProvider parent, CellInformation cell) : base(parent, TableItemPattern.Pattern, GridItemPattern.Pattern)
 {
     _cell       = cell;
     ControlType = ControlType.Text;
 }
Exemple #11
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();
 }
Exemple #12
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;
 }
        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();
            }
        }
Exemple #14
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;
 }
Exemple #15
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();
 }
Exemple #16
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;
 }
Exemple #17
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;
 }
Exemple #18
0
 /// <summary>
 /// Prevents a default instance of the <see cref="Value"/> 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 Value(AutomationProvider provider, CommandManager manager, ExpectType expectType) : base(provider, manager)
 {
     _expectType = expectType;
 }
Exemple #19
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;
 }
Exemple #20
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;
 }
Exemple #21
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;
 }
Exemple #22
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;
 }
Exemple #23
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;
 }
 /// <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;
 }
Exemple #25
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="value">The value.</param>
 public Text(AutomationProvider provider, CommandManager manager, string value)
     : base(provider, manager)
 {
     _value = value;
 }
Exemple #26
0
 private void RaiseAutomationIsSelectedChanged(bool oldValue, bool newValue)
 {
     AutomationProvider.RaiseAutomationPropertyChangedEvent(this, SelectionItemPatternIdentifiers.IsSelectedProperty, oldValue, newValue);
 }
 public TableCellProvider(AutomationProvider parent, CellInformation cell) : base(parent, TableItemPattern.Pattern, GridItemPattern.Pattern)
 {
     _cell = cell;
     ControlType = ControlType.Text;
 }
Exemple #28
0
 public CommandBase(AutomationProvider provider, CommandManager manager)
 {
     Provider       = provider;
     CommandManager = manager;
 }
Exemple #29
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;
 }