Beispiel #1
0
        /// <summary>
        /// Finds UIItem which matches specified type and searchCriteria. Look at documentation of SearchCriteria for details on it.
        /// </summary>
        /// <param name="searchCriteria">Criteria provided to search UIItem</param>
        /// <param name="timeout">Time to wait for item to come on-screen before returning off-screen element, if found.</param>
        /// <returns>First items matching the criteria</returns>
        public virtual IUIItem Get(SearchCriteria searchCriteria, TimeSpan timeout)
        {
            try
            {
                var uiItem = Retry.For(() =>
                                       CurrentContainerItemFactory.Find(searchCriteria, WindowSession),
                                       b => (bool)b.AutomationElement.GetCurrentPropertyValue(AutomationElement.IsOffscreenProperty, false),
                                       timeout);

                if (uiItem == null)
                {
                    var debugDetails = Debug.Details(automationElement);
                    throw new AutomationException(string.Format("Failed to get {0}", searchCriteria), debugDetails);
                }

                HandleIfCustomUIItem(uiItem);
                HandleIfUIItemContainer(uiItem);
                return(uiItem);
            }
            catch (AutomationException)
            {
                throw;
            }
            catch (Exception e)
            {
                var debugDetails = Debug.Details(automationElement);

                throw new WhiteException(string.Format("Error occured while geting {0}", searchCriteria), debugDetails, e);
            }
        }
 /// <summary>
 /// Finds UIItem which matches specified type and searchCriteria. Look at documentation of SearchCriteria for details on it.
 /// </summary>
 /// <param name="searchCriteria">Criteria provided to search UIItem</param>
 /// <returns>First items matching the criteria</returns>
 public virtual IUIItem Get(SearchCriteria searchCriteria)
 {
     try
     {
         IUIItem uiItem = currentContainerItemFactory.Find(searchCriteria, windowSession);
         HandleIfCustomUIItem(uiItem);
         HandleIfUIItemContainer(uiItem);
         return(uiItem);
     }
     catch (Exception e)
     {
         throw new WhiteException(Debug.Details(automationElement), e);
     }
 }