Exemplo n.º 1
0
        public override TResult RunQuery <TResult>(IAutoBotQuery <TResult> query, string componentName)
        {
            string queryString = $"{ componentName }::{ query.GetType().Name }";

            try
            {
                TResult result = default(TResult);

                Exception[] exceptions = RunIterativelyAndCollectExceptions(queryString, () =>
                {
                    result = base.RunQuery(query, componentName);
                });

                if (exceptions.Length > 0)
                {
                    throw new AutoBotQueryFailedException <TResult>(query, componentName, exceptions);
                }

                return(result);
            }
            catch
            {
                _logger.TakeScreenshot($"Error: { queryString } Test Failed.");

                throw;
            }
        }
        public virtual TResult RunQuery <TResult>(IAutoBotQuery <TResult> query, string componentName)
        {
            _logger.LogVerbose($"Target component key is: { componentName }");

            string queryClassName = query.GetType().Name;

            _logger.LogVerbose($"Current query is: { queryClassName }");

            Source source          = _navigator.GetCurrentSource();
            string sourceClassName = source.GetType().Name;

            _logger.LogVerbose($"Current source is: { sourceClassName }");

            object component          = source.GetComponent(componentName);
            string componentClassName = component.GetType().Name;

            _logger.LogVerbose($"Current component is: { componentClassName }");

            TResult result = query.Run(component);

            _logger.LogVerbose($"{ componentName }::{ queryClassName }::{ sourceClassName }::{ componentClassName } query returned { result.ToString() }.");

            return(result);
        }
 public AutoBotQueryFailedException(IAutoBotQuery <TResult> query, string componentName, IEnumerable <Exception> innerExceptions)
     : base($"{query.GetType().Name} query failed on '{componentName}'", innerExceptions)
 {
     Query         = query;
     ComponentName = componentName;
 }