示例#1
0
        private IEnumerable <TElement> GetAndWaitWebDriverElements()
        {
            var elementWaiter = new ElementWaitService <TDriver, TDriverElement>();

            elementWaiter.WaitInternal(_by, new WaitToExistStrategy <TDriver, TDriverElement>());

            var nativeElements = _mobileElement == null
                ? _by.FindAllElements(WrappedDriver)
                : _by.FindAllElements(_mobileElement);

            foreach (var nativeElement in nativeElements)
            {
                var            elementRepository = new ElementRepository();
                var            wrappedDriver     = ServicesCollection.Current.Resolve <TDriver>();
                TDriverElement currentNativeElement;
                if (wrappedDriver is AndroidDriver <AndroidElement> )
                {
                    currentNativeElement = (TDriverElement)Activator.CreateInstance(typeof(AndroidElement), wrappedDriver, nativeElement.Id);
                }
                else
                {
                    currentNativeElement = (TDriverElement)Activator.CreateInstance(typeof(IOSElement), wrappedDriver, nativeElement.Id);
                }

                yield return(elementRepository.CreateElementThatIsFound <TElement, TBy, TDriver, TDriverElement>(_by, currentNativeElement));
            }
        }
示例#2
0
        public TElement Create <TElement, TBy>(TBy by)
            where TBy : FindStrategy
            where TElement : Element
        {
            var elementRepository = new ElementRepository();

            return(elementRepository.CreateElementThatIsFound <TElement>(by, null));
        }
        public TElement Create <TElement, TBy, TDriver, TDriverElement>(TBy by)
            where TElement : Element <TDriver, TDriverElement>
            where TBy : FindStrategy <TDriver, TDriverElement>
            where TDriver : AppiumDriver <TDriverElement>
            where TDriverElement : AppiumWebElement
        {
            var elementRepository = new ElementRepository();

            return(elementRepository.CreateElementThatIsFound <TElement, TBy, TDriver, TDriverElement>(by, null));
        }
示例#4
0
        private IEnumerable <TElement> GetAndWaitWebDriverElements()
        {
            if (_shouldCacheFoundElements && _cachedElements == null)
            {
                _cachedElements = GetAndWaitNativeElements().ToList();
            }

            if (_shouldCacheFoundElements && _cachedElements != null)
            {
                foreach (var element in _cachedElements)
                {
                    yield return(element);
                }
            }
            else
            {
                foreach (var element in GetAndWaitNativeElements())
                {
                    yield return(element);
                }
            }

            IEnumerable <TElement> GetAndWaitNativeElements()
            {
                foreach (var foundElement in _foundElements)
                {
                    yield return(foundElement);
                }

                if (_parentElement != null)
                {
                    var elementRepository = new ElementRepository();
                    foreach (var nativeElement in _by?.FindAllElements(_parentElement))
                    {
                        var element =
                            elementRepository.CreateElementThatIsFound <TElement>(_by, (WindowsElement)nativeElement);
                        yield return(element);
                    }
                }
                else
                {
                    var elementRepository = new ElementRepository();
                    foreach (var nativeElement in _by?.FindAllElements(WrappedDriver))
                    {
                        var element =
                            elementRepository.CreateElementThatIsFound <TElement>(_by, nativeElement);
                        yield return(element);
                    }
                }
            }
        }
示例#5
0
 public void Wait <TUntil, TElement>(TElement element, TUntil until)
     where TUntil : WaitStrategy
     where TElement : Element
 {
     try
     {
         if (element.ParentWrappedElement == null)
         {
             WaitInternal(element.By, until);
         }
         else
         {
             var     elementRepository = new ElementRepository();
             Element parentElement     = elementRepository.CreateElementThatIsFound <Element>(element.By, element.ParentWrappedElement, true);
             WaitInternal(element.By, until, parentElement);
         }
     }
     catch (Exception ex)
     {
         OnElementNotFulfillingWaitConditionEvent?.Invoke(this, new ElementNotFulfillingWaitConditionEventArgs(ex));
         throw;
     }
 }