示例#1
0
        protected internal override void Execute <TOwner>(TriggerContext <TOwner> context)
        {
            ScopeSource actualScopeSource = scopeSource ?? context.Component.ScopeSource;
            IWebElement scopeElement      = actualScopeSource.GetScopeElement(context.Component);

            WaitUnit[] waitUnits = GetWaitUnits(Until);

            Wait(scopeElement, waitUnits);
        }
示例#2
0
 public StrategyScopeLocatorExecutionData(
     UIComponent component,
     ScopeSource scopeSource,
     bool isSafely,
     IEnumerable <StrategyScopeLocatorLayerExecutionUnit> layerUnits,
     StrategyScopeLocatorExecutionUnit finalUnit)
 {
     Component   = component;
     ScopeSource = scopeSource;
     IsSafely    = isSafely;
     LayerUnits  = layerUnits;
     FinalUnit   = finalUnit;
 }
示例#3
0
        public List <InstructionIDNamePair> GetAllSubroutines(ScopeSource source)
        {
            var bhavs  = GetAllResource <BHAV>(source);
            var output = new List <InstructionIDNamePair>();

            foreach (var bhav in bhavs)
            {
                output.Add(new InstructionIDNamePair(bhav.ChunkLabel, bhav.ChunkID));
            }

            output = output.OrderBy(o => o.Name).ToList();
            return(output);
        }
示例#4
0
        public string GetFilename(ScopeSource scope)
        {
            switch (scope)
            {
            case ScopeSource.Global:
                return("global");

            case ScopeSource.SemiGlobal:
                return(SemiGlobalName);

            default:
                return(Object.Resource.Name);
            }
        }
示例#5
0
        public T GetResource <T>(ushort id, ScopeSource source)
        {
            switch (source)
            {
            case ScopeSource.Private:
                return(Object.Resource.Get <T>(id));

            case ScopeSource.SemiGlobal:
                return(SemiGlobal.Get <T>(id));

            case ScopeSource.Global:
                return(Globals.Resource.Get <T>(id));

            default:
                return(default(T));
            }
        }
示例#6
0
        public List <T> GetAllResource <T>(ScopeSource source)
        {
            switch (source)
            {
            case ScopeSource.Private:
                return(Object.Resource.List <T>());

            case ScopeSource.SemiGlobal:
                return((SemiGlobal == null) ? new List <T>():SemiGlobal.List <T>());

            case ScopeSource.Global:
                return(Globals.Resource.List <T>());

            default:
                return(new List <T>());
            }
        }
示例#7
0
        public List <T> GetAllResource <T>(ScopeSource source)
        {
            switch (source)
            {
            case ScopeSource.Private:
                return((Resource is GameGlobalResource)? new List <T>():Resource.List <T>());

            case ScopeSource.SemiGlobal:
                return((Resource.SemiGlobal == null) ? new List <T>():Resource.SemiGlobal.List <T>());

            case ScopeSource.Global:
                return(EditorScope.Globals.Resource.List <T>());

            default:
                return(new List <T>());
            }
        }
示例#8
0
        public static IWebElement GetScopeElement(this ScopeSource scopeSource, UIComponent component)
        {
            switch (scopeSource)
            {
            case ScopeSource.Parent:
                return(component.Parent.Scope);

            case ScopeSource.Grandparent:
                return(component.Parent.Parent.Scope);

            case ScopeSource.PageObject:
                return(component.Owner.Scope);

            case ScopeSource.Page:
                return(component.Driver.Get(By.TagName("body")));

            default:
                throw ExceptionFactory.CreateForUnsupportedEnumValue(scopeSource, nameof(scopeSource));
            }
        }
示例#9
0
        public static IWebElement GetScopeElementUsingParent <TOwner>(this ScopeSource scopeSource, IUIComponent <TOwner> parentComponent)
            where TOwner : PageObject <TOwner>
        {
            switch (scopeSource)
            {
            case ScopeSource.Parent:
                return(parentComponent.Scope);

            case ScopeSource.Grandparent:
                return(parentComponent.Parent.Scope);

            case ScopeSource.PageObject:
                return(parentComponent.Owner.Scope);

            case ScopeSource.Page:
                return(AtataContext.Current.Driver.Get(By.TagName("body")));

            default:
                throw ExceptionFactory.CreateForUnsupportedEnumValue(scopeSource, nameof(scopeSource));
            }
        }
        public static ISearchContext GetScopeContextUsingParent <TOwner>(this ScopeSource scopeSource, IUIComponent <TOwner> parentComponent)
            where TOwner : PageObject <TOwner>
        {
            switch (scopeSource)
            {
            case ScopeSource.Parent:
                return(parentComponent.ScopeContext);

            case ScopeSource.Grandparent:
                return((parentComponent.Parent ?? throw UIComponentNotFoundException.ForParentOf(parentComponent.ComponentFullName)).ScopeContext);

            case ScopeSource.PageObject:
                return(parentComponent.Owner.ScopeContext);

            case ScopeSource.Page:
                return((parentComponent?.Context ?? AtataContext.Current).Driver);

            default:
                throw ExceptionFactory.CreateForUnsupportedEnumValue(scopeSource, nameof(scopeSource));
            }
        }
        public StrategyScopeLocatorExecutionData Get(SearchOptions searchOptions)
        {
            searchOptions = searchOptions ?? new SearchOptions();

            FindAttribute[] layerFindAttributes = _component.Metadata.ResolveLayerFindAttributes().ToArray();

            FindAttribute findAttribute = _component.Metadata.ResolveFindAttribute();

            var layerExecutionUnits = layerFindAttributes
                                      .Select(x => CreateExecutionUnitForLayerFindAttribute(x, searchOptions))
                                      .ToArray();

            var finalExecutionUnit = CreateExecutionUnitForFinalFindAttribute(findAttribute, searchOptions);

            ScopeSource scopeSource = layerFindAttributes.Any() && layerFindAttributes[0].Properties.Contains(nameof(FindAttribute.ScopeSource))
                ? layerFindAttributes[0].ScopeSource
                : findAttribute.ScopeSource;

            PostProcessOuterXPath(layerExecutionUnits, finalExecutionUnit);

            return(new StrategyScopeLocatorExecutionData(_component, scopeSource, searchOptions.IsSafely, layerExecutionUnits, finalExecutionUnit));
        }
示例#12
0
        public static ISearchContext GetScopeContext(this ScopeSource scopeSource, UIComponent component, SearchOptions options = null)
        {
            options = options ?? new SearchOptions();

            switch (scopeSource)
            {
            case ScopeSource.Parent:
                return(component.Parent.GetScopeContext(options));

            case ScopeSource.Grandparent:
                return(component.Parent.Parent.GetScopeContext(options));

            case ScopeSource.PageObject:
                return(component.Owner.GetScopeContext(options));

            case ScopeSource.Page:
                return(component.Driver);

            default:
                throw ExceptionFactory.CreateForUnsupportedEnumValue(scopeSource, nameof(scopeSource));
            }
        }
示例#13
0
        public List <InstructionIDNamePair> GetAllSubroutines(ScopeSource source)
        {
            var bhavs = GetAllResource <BHAV>(source);

            if (source == ScopeSource.SemiGlobal && Resource is GameGlobalResource)
            {
                bhavs = Resource.List <BHAV>();
            }
            var output = new List <InstructionIDNamePair>();

            if (bhavs == null)
            {
                return(output);
            }
            foreach (var bhav in bhavs)
            {
                output.Add(new InstructionIDNamePair(bhav.ChunkLabel, bhav.ChunkID));
            }

            output = output.OrderBy(o => o.Name).ToList();
            return(output);
        }
示例#14
0
        [Obsolete("Use GetScopeContext(...) instead.")] // Obsolete since v1.5.0.
        public static IWebElement GetScopeElement(this ScopeSource scopeSource, UIComponent component, SearchOptions options = null)
        {
            options = options ?? new SearchOptions();

            switch (scopeSource)
            {
            case ScopeSource.Parent:
                return(component.Parent.GetScope(options));

            case ScopeSource.Grandparent:
                return(component.Parent.Parent.GetScope(options));

            case ScopeSource.PageObject:
                return(component.Owner.GetScope(options));

            case ScopeSource.Page:
                return(component.Driver.GetWithLogging(By.TagName("body").With(options)));

            default:
                throw ExceptionFactory.CreateForUnsupportedEnumValue(scopeSource, nameof(scopeSource));
            }
        }
示例#15
0
        protected virtual void Wait <TOwner>(IUIComponent <TOwner> scopeComponent, WaitUnit waitUnit)
            where TOwner : PageObject <TOwner>
        {
            ScopeSource actualScopeSource = scopeSource ?? scopeComponent.ScopeSource;

            StaleSafely.Execute(
                options =>
            {
                ISearchContext scopeContext = actualScopeSource.GetScopeContext(scopeComponent, SearchOptions.Within(options.Timeout));

                By by = WaitBy.GetBy(Selector).With(options);

                if (waitUnit.Method == WaitUnit.WaitMethod.Presence)
                {
                    scopeContext.Exists(by);
                }
                else
                {
                    scopeContext.Missing(by);
                }
            },
                waitUnit.SearchOptions);
        }
示例#16
0
 public ReadOnlyCollection <IWebElement> GetAll(string xPathCondition = null)
 {
     return(ScopeSource.GetAll(CreateBy(xPathCondition)));
 }
示例#17
0
 public IWebElement Get(string xPathCondition = null)
 {
     return(ScopeSource.Get(CreateBy(xPathCondition)));
 }
示例#18
0
 [Obsolete("Use GetScopeContext(...) instead.")] // Obsolete since v1.5.0.
 public static IWebElement GetScopeElement <TOwner>(this ScopeSource scopeSource, IUIComponent <TOwner> component, SearchOptions options = null)
     where TOwner : PageObject <TOwner>
 {
     return(GetScopeElement(scopeSource, (UIComponent)component, options));
 }
示例#19
0
 public static IWebElement GetScopeElement <TOwner>(this ScopeSource scopeSource, IUIComponent <TOwner> component)
     where TOwner : PageObject <TOwner>
 {
     return(GetScopeElement(scopeSource, (UIComponent)component));
 }