Example #1
0
        public static By From(FindsByAttribute attribute)
        {
            How    how    = attribute.How;
            string @using = attribute.Using;

            switch (how)
            {
            case How.Id:
                return(By.Id(@using));

            case How.Name:
                return(By.Name(@using));

            case How.TagName:
                return(By.TagName(@using));

            case How.ClassName:
                return(By.ClassName(@using));

            case How.CssSelector:
                return(By.CssSelector(@using));

            case How.LinkText:
                return(By.LinkText(@using));

            case How.PartialLinkText:
                return(By.PartialLinkText(@using));

            case How.XPath:
                return(By.XPath(@using));
            }
            throw new ArgumentException(string
                                        .Format(CultureInfo.InvariantCulture, "Did not know how to construct How from how {0}, using {1}",
                                                new object[] { how, @using }));
        }
Example #2
0
        internal static IWebElement FindElement(string select, How selector, ISearchContext context, int elementTimeOut = 2000)
        {
            switch (selector)
            {
            case How.ClassName:
                return(WaitandReturnElementExists(By.ClassName(select), context, elementTimeOut));

            case How.CssSelector:
                return(WaitandReturnElementExists(By.CssSelector(select), context, elementTimeOut));

            case How.Id:
                return(WaitandReturnElementExists(By.Id(select), context, elementTimeOut));

            case How.LinkText:
                return(WaitandReturnElementExists(By.LinkText(select), context, elementTimeOut));

            case How.Name:
                return(WaitandReturnElementExists(By.Name(select), context, elementTimeOut));

            case How.PartialLinkText:
                return(WaitandReturnElementExists(By.PartialLinkText(select), context, elementTimeOut));

            case How.TagName:
                return(WaitandReturnElementExists(By.TagName(select), context, elementTimeOut));

            case How.XPath:
                return(WaitandReturnElementExists(By.XPath(select), context, elementTimeOut));
            }
            throw new NotSupportedException(string.Format("Selector \"{0}\" is not supported.", selector));
        }
        public IWebElement FindBy(How how, string locator, int index = 0)
        {
            switch (how)
            {
            case How.Id:
                Wait.InterceptedFindUntil((x, l) => x.FindElements(By.Id(l)).Count > index, locator);
                return(WebDriver.FindElements(By.Id(locator))[index]);

            case How.Name:
                Wait.InterceptedFindUntil((x, l) => x.FindElements(By.Name(l)).Count > index, locator);
                return(WebDriver.FindElements(By.Name(locator))[index]);

            case How.ClassName:
                Wait.InterceptedFindUntil((x, l) => x.FindElements(By.ClassName(l)).Count > index, locator);
                return(WebDriver.FindElements(By.ClassName(locator))[index]);

            case How.LinkText:
                Wait.InterceptedFindUntil((x, l) => x.FindElements(By.LinkText(l)).Count > index, locator);
                return(WebDriver.FindElements(By.LinkText(locator))[index]);

            case How.PartialLinkText:
                Wait.InterceptedFindUntil((x, l) => x.FindElements(By.PartialLinkText(l)).Count > index, locator);
                return(WebDriver.FindElements(By.PartialLinkText(locator))[index]);

            case How.CssSelector:
                Wait.InterceptedFindUntil((x, l) => x.FindElements(By.CssSelector(l)).Count > index, locator);
                return(WebDriver.FindElements(By.CssSelector(locator))[index]);

            default:
                Wait.InterceptedFindUntil((x, l) => x.FindElements(By.XPath(l)).Count > index, locator);
                return(WebDriver.FindElements(By.XPath(locator))[index]);
            }
        }
        public static By Create(How how, string usingValue, Type customFinderType = null) {

            if (string.IsNullOrWhiteSpace(usingValue) && how == How.Custom)
            {
                throw new ArgumentException(string.Format("[Using] should not be empty when [How={0}]", how));
            }
                
            switch (how) {
                case How.Id:
                    return By.Id(usingValue);
                case How.Name:
                    return By.Name(usingValue);
                case How.TagName:
                    return By.TagName(usingValue);
                case How.ClassName:
                    return By.ClassName(usingValue);
                case How.CssSelector:
                    return By.CssSelector(usingValue);
                case How.LinkText:
                    return By.LinkText(usingValue);
                case How.PartialLinkText:
                    return By.PartialLinkText(usingValue);
                case How.XPath:
                    return By.XPath(usingValue);
                case How.Custom:
                    return Create(customFinderType, usingValue);
            }

            throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                "Cannot construct [By] from [How={0}], [Using={1}]", how, usingValue));
        }
Example #5
0
        /// <summary>
        /// Gets an instance of the <see cref="By"/> class based on the specified attribute.
        /// </summary>
        /// <param name="attribute">The <see cref="OpenQA.Selenium.Support.PageObjects.FindsByAttribute"/> describing how to find the element.</param>
        /// <returns>An instance of the <see cref="By"/> class.</returns>
        public static By From(LocateAttribute attribute)
        {
            How    how           = attribute.How;
            string strUsingValue = attribute.Using;

            switch (how)
            {
            case How.Id:
                return(By.Id(strUsingValue));

            case How.Name:
                return(By.Name(strUsingValue));

            case How.TagName:
                return(By.TagName(strUsingValue));

            case How.ClassName:
                return(By.ClassName(strUsingValue));

            case How.CssSelector:
                return(By.CssSelector(strUsingValue));

            case How.LinkText:
                return(By.LinkText(strUsingValue));

            case How.PartialLinkText:
                return(By.PartialLinkText(strUsingValue));

            case How.XPath:
                return(By.XPath(strUsingValue));
            }

            throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Did not know how to construct How from how {0}, using {1}", how, strUsingValue));
        }
Example #6
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (buzz_ != null)
            {
                hash ^= Buzz.GetHashCode();
            }
            if (Where.Length != 0)
            {
                hash ^= Where.GetHashCode();
            }
            if (Who.Length != 0)
            {
                hash ^= Who.GetHashCode();
            }
            if (How.Length != 0)
            {
                hash ^= How.GetHashCode();
            }
            if (What.Length != 0)
            {
                hash ^= What.GetHashCode();
            }
            if (Why.Length != 0)
            {
                hash ^= Why.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #7
0
        internal By GetByLocator(How findBy, string findByValue)
        {
            switch (findBy)
            {
            case How.Id:
                return(By.Id(findByValue));

            case How.TagName:
                return(By.TagName(findByValue));

            case How.Name:
                return(By.Name(findByValue));

            case How.ClassName:
                return(By.ClassName(findByValue));

            case How.Xpath:
                return(By.XPath(findByValue));

            case How.CssSelector:
                return(By.CssSelector(findByValue));

            case How.LinkText:
                return(By.LinkText(findByValue));

            case How.PartialLinkText:
                return(By.PartialLinkText(findByValue));

            default:
                throw new Exception("Not a valid Locator type: " + findBy);
            }
        }
Example #8
0
        public static By GetLocator(this How how, string value)
        {
            switch (how)
            {
            case How.Id:
                return(By.Id(value));

            case How.Name:
                return(By.Name(value));

            case How.TagName:
                return(By.TagName(value));

            case How.ClassName:
                return(By.ClassName(value));

            case How.CssSelector:
                return(By.CssSelector(value));

            case How.LinkText:
                return(By.LinkText(value));

            case How.PartialLinkText:
                return(By.PartialLinkText(value));

            case How.XPath:
                return(By.XPath(value));

            default:
                throw new Exception($"Can't get locator How.{how} for {value} value.");
            }
        }
Example #9
0
 public JDropDown(string root, string value, string list, string expander, How how = How.CssSelector)
 {
     RootLocator = how.GetLocator(root);
     ValueLocator = how.GetLocator(value);
     ListLocator = how.GetLocator(list);
     ExpandLocator = how.GetLocator(expander);
 }
Example #10
0
        public static By From(How how, string usingStr)
        {
            switch (how)
            {
            case How.Id:
                return(By.Id(usingStr));

            case How.Name:
                return(By.Name(usingStr));

            case How.TagName:
                return(By.TagName(usingStr));

            case How.ClassName:
                return(By.ClassName(usingStr));

            case How.CssSelector:
                return(By.CssSelector(usingStr));

            case How.LinkText:
                return(By.LinkText(usingStr));

            case How.PartialLinkText:
                return(By.PartialLinkText(usingStr));

            case How.XPath:
                return(By.XPath(usingStr));

            default:
                throw new UnsupportedIdentityTypeException(string.Format("Unable to locate an Identity using locateor type: {0}", how));
            }
        }
Example #11
0
        public IActionResult Put(How how)
        {
            UserProfile user = GetCurrentUserProfile();

            _howRepository.Update(how, user.Id);
            return(NoContent());
        }
Example #12
0
        public IWebElement SearchElement(IWebElement rooElement = null)
        {
            How    how         = GetFindMethod(_by);
            string usingString = GetUsingString(how, _by);

            return(SearchElement(how, usingString, rooElement));
        }
Example #13
0
        public List <RemoteWebElement> SearchElements(By by, IWebElement rootField = null)
        {
            How    how         = GetFindMethod(by);
            string usingString = GetUsingString(how, by);

            return(SearchElements(how, usingString, rootField));
        }
Example #14
0
        internal void DragAndDrop(How findBy, string findByValue, How targetFindBy, string targetFindByValue)
        {
            var element       = FindElement(findBy, findByValue);
            var targetElement = FindElement(targetFindBy, targetFindByValue);

            _actions.DragAndDrop(element, targetElement).Perform();
        }
Example #15
0
        public By GetElementLocator(How locator, string locatorValue)
        {
            switch (locator)
            {
            case How.XPath:
                return(By.XPath(locatorValue));

            case How.ClassName:
                return(By.ClassName(locatorValue));

            case How.CssSelector:
                return(By.CssSelector(locatorValue));

            case How.LinkText:
                return(By.LinkText(locatorValue));

            case How.Name:
                return(By.Name(locatorValue));

            case How.PartialLinkText:
                return(By.PartialLinkText(locatorValue));

            default:
                return(By.Id(locatorValue));
            }
        }
        public FindsByAttribute(How how, string usingstring)

        {
            How = how;

            Using = usingstring;
        }
Example #17
0
        /// <summary>
        /// Create a By accessor from a By method (How) and string (Using).
        /// </summary>
        /// <param name="how">type of By</param>
        /// <param name="usingValue">string to use</param>
        /// <returns>By accessor created</returns>
        public static By CreateBy(How how, string usingValue)
        {
            switch (how)
            {
            case How.Id:
                return(By.Id(usingValue));

            case How.Name:
                return(By.Name(usingValue));

            case How.TagName:
                return(By.TagName(usingValue));

            case How.ClassName:
                return(By.ClassName(usingValue));

            case How.CssSelector:
                return(By.CssSelector(usingValue));

            case How.LinkText:
                return(By.LinkText(usingValue));

            case How.PartialLinkText:
                return(By.PartialLinkText(usingValue));

            case How.XPath:
                return(By.XPath(usingValue));

            default:
                //Log.Error(String.Format("Cannot construct By from How={0}, Using={1}", how, usingValue));
                throw new ArgumentException();
            }
        }
Example #18
0
            //
            // Static Methods
            //
            public static By From(FindsByAttribute attribute)
            {
                How    how    = attribute.How;
                string @using = attribute.Using;

                switch (how)
                {
                case How.Id:
                    return(By.Id(@using));

                case How.Name:
                    return(By.Name(@using));

                case How.TagName:
                    return(By.TagName(@using));

                case How.ClassName:
                    return(By.ClassName(@using));

                case How.CssSelector:
                    return(By.CssSelector(@using));

                case How.LinkText:
                    return(By.LinkText(@using));

                case How.PartialLinkText:
                    return(By.PartialLinkText(@using));

                case How.XPath:
                    return(By.XPath(@using));

                case How.Custom: {
                    if (attribute.CustomFinderType == null)
                    {
                        throw new ArgumentException("Cannot use How.Custom without supplying a custom finder type");
                    }
                    if (!attribute.CustomFinderType.IsSubclassOf(typeof(By)))
                    {
                        throw new ArgumentException("Custom finder type must be a descendent of the By class");
                    }
                    ConstructorInfo constructor = attribute.CustomFinderType.GetConstructor(new Type[] {
                            typeof(string)
                        });
                    if (constructor == null)
                    {
                        throw new ArgumentException("Custom finder type must expose a public constructor with a string argument");
                    }
                    return(constructor.Invoke(new object[] {
                            @using
                        }) as By);
                }

                default:
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Did not know how to construct How from how {0}, using {1}", new object[] {
                        how,
                        @using
                    }));
                }
            }
Example #19
0
        public static void ClickAndHold(How locator, string value)
        {
            var action     = new Actions(WebDriver);
            var webElement = FindElement(locator, value);

            action.MoveToElement(webElement).Click();
            action.MoveToElement(webElement).ClickAndHold().Build().Perform();
        }
Example #20
0
        private List <IWebElement> FindParrentFields()
        {
            _parrentFields = new List <IWebElement>();
            IWebElement previuosElement = null;

            for (int i = 0; i < _parrentFieldSelectors.Count; i++)
            {
                How    how         = GetFindMethod(_parrentFieldSelectors[i]);
                string usingString = GetUsingString(how, _parrentFieldSelectors[i]);
                if (i.Equals(0))
                {
                    //Try search first in regular DOM
                    try
                    {
                        if (_parrentField != null)
                        {
                            previuosElement = _parrentField.FindElement(_parrentFieldSelectors[i]);
                        }
                        else
                        {
                            previuosElement = _webdriver.FindElement(_parrentFieldSelectors[i]);
                        }

                        _parrentFields.Add(previuosElement);
                        continue;
                    }
                    catch (Exception)
                    {
                        //ignored
                    }

                    //search in shadowdom
                    try
                    {
                        previuosElement = SearchElements(how, usingString, _parrentField).First();
                        _parrentFields.Add(previuosElement);
                        continue;
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Failed to find first parrent field", e);
                    }
                }

                try
                {
                    var subsequentElement = SearchElement(_parrentFieldSelectors[i], previuosElement);
                    _parrentFields.Add(subsequentElement);
                    previuosElement = subsequentElement;
                }
                catch (Exception e)
                {
                    throw new Exception($"Failed to find subsequent element using: {_parrentFieldSelectors[i]}", e);
                }
            }

            return(_parrentFields);
        }
        public IEnumerable <TElement> FindAll <TElement>(How how, string @using) where TElement : IHtmlElement, new()
        {
            var elementsCollection = CollectionFactory.Create <TElement>(this, new Locator(how, @using));

            foreach (var element in elementsCollection)
            {
                yield return(element);
            }
        }
Example #22
0
        public How GetRandomHow(int dreamId, int userProfileId, int timeAvailable)
        {
            using (var conn = Connection)
            {
                conn.Open();
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = @"SELECT TOP 1 Id, Description, TimeToComplete, IsRepeatable, DreamId, Name, IsDeactivated, UserProfileId
                                                FROM 
		                                        (
				                                        SELECT DISTINCT h.Id, h.Description, h.TimeToComplete, h.IsRepeatable, h.DreamId,
								                                        d.Name, d.IsDeactivated, d.UserProfileId
				                                          FROM How h
			                                              JOIN Dream d ON h.DreamId = d.Id
	                                                 LEFT JOIN CompletedHow ch ON h.Id = ch.HowId 
				                                         WHERE (ch.Id IS NULL OR h.IsRepeatable = 1) 
				                                           AND (h.DreamId = @dreamId AND d.UserProfileId = @userProfileId AND h.IsDeleted = 0)
				                                           )
                                        AS HowOptions
                                        WHERE TimeToComplete <= @timeAvailable
                                        ORDER BY NEWID();";

                    cmd.Parameters.AddWithValue("@dreamId", dreamId);
                    cmd.Parameters.AddWithValue("@userProfileId", userProfileId);
                    cmd.Parameters.AddWithValue("@timeAvailable", timeAvailable);

                    var reader = cmd.ExecuteReader();

                    if (reader.Read())
                    {
                        How how = new How()
                        {
                            Id             = DbUtils.GetInt(reader, "Id"),
                            Description    = DbUtils.GetString(reader, "Description"),
                            TimeToComplete = DbUtils.GetInt(reader, "TimeToComplete"),
                            IsRepeatable   = DbUtils.GetInt(reader, "IsRepeatable"),
                            DreamId        = DbUtils.GetInt(reader, "DreamId"),
                            Dream          = new Dream()
                            {
                                Id            = DbUtils.GetInt(reader, "DreamId"),
                                Name          = DbUtils.GetString(reader, "Name"),
                                IsDeactivated = DbUtils.GetInt(reader, "IsDeactivated"),
                                UserProfileId = DbUtils.GetInt(reader, "UserProfileId"),
                            }
                        };
                        reader.Close();
                        return(how);
                    }
                    else
                    {
                        reader.Close();
                        return(null);
                    }
                }
            }
        }
Example #23
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ApplianceName?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ (ApplianceInstanceName?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (How?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ Where.GetHashCode();
         return(hashCode);
     }
 }
        private static string GetMessage(How findBy, string findByValue, Exception inner)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Couldn't locate element with findBy:");
            sb.Append(findBy.ToString());
            sb.Append(" and findbyvalue: ");
            sb.Append(findByValue);
            sb.Append(".Exception Message:");
            sb.Append(inner.Message);
            return(sb.ToString());
        }
Example #25
0
        private static string GetMessage(How findBy, string findByValue, Exception inner)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Exception while Waiting for the Element with FindBy");
            sb.Append(findBy.ToString());
            sb.Append(" and findbyvalue: ");
            sb.Append(findByValue);
            sb.Append(".Exception Message:");
            sb.Append(inner.Message);
            return(sb.ToString());
        }
Example #26
0
        /// <summary>
        /// Search for IwebElement in ShadowDOM.
        /// </summary>
        /// <param name="how"></param>
        /// <param name="usingString"></param>
        /// <param name="rootElement">If rootElement is defined then the search is performed inside rootElement</param>
        /// <returns></returns>
        /// <exception cref="NoSuchElementException"></exception>
        public IWebElement SearchElement(How how, string usingString, IWebElement rootElement = null)
        {
            List <RemoteWebElement> elementsList;

            elementsList = SearchElements(how, usingString, rootElement);
            if (elementsList.Count > 0)
            {
                return(elementsList.First());
            }

            throw new NoSuchElementException($"Failed to find element in shadowDom By:{_by}");
        }
Example #27
0
 public static List<IWebElement> FindElements(string selector, How how)
 {
     switch (how)
     {
         case How.CssSelector:
             return _webDriver.FindElements(By.CssSelector(selector)).ToList();
         case How.XPath:
             return _webDriver.FindElements(By.XPath(selector)).ToList();
         default:
             return _webDriver.FindElements(By.Id(selector)).ToList();
     }
 }
        public List <List <string> > GetTableValues(How RowLocator, string RowValue, How rowDetailsLocator, string rowDetailsValue)
        {
            var tableDetails = new List <List <string> >();
            int rowCount     = Browser.FindElements(RowLocator, RowValue).Count;

            for (int i = 1; i <= rowCount; i++)
            {
                var rowDetails = GetTableValuesListByRow(rowDetailsLocator, rowDetailsValue, i);
                tableDetails.Add(rowDetails);
            }
            return(tableDetails);
        }
Example #29
0
        internal void WaitTillElementsArePresent(How findBy, string findByvalue, int seconds = 60)
        {
            try
            {
                var wait = new WebDriverWait(_nativeWebDriver, TimeSpan.FromSeconds(seconds));
                wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(GetByLocator(findBy, findByvalue)));
            }

            catch (Exception ex)
            {
                throw new WaitForElementException(findBy, findByvalue, ex);
            }
        }
Example #30
0
        internal void WaitTillTextToBePresent(How findBy, string findByValue, string text, int seconds = 60)
        {
            try
            {
                var wait = new WebDriverWait(_nativeWebDriver, TimeSpan.FromSeconds(seconds));
                wait.Until(ExpectedConditions.TextToBePresentInElement(FindElement(findBy, findByValue), text));
            }

            catch (Exception ex)
            {
                throw new WaitForElementException("Text", text, ex);
            }
        }
Example #31
0
        internal void WaitTillElementisInvisible(How findBy, string findByValue, int seconds = 60)
        {
            try
            {
                var wait = new WebDriverWait(_nativeWebDriver, TimeSpan.FromSeconds(seconds));
                wait.Until(ExpectedConditions.InvisibilityOfElementLocated(GetByLocator(findBy, findByValue)));
            }

            catch (Exception ex)
            {
                throw new WaitForElementException(findBy, findByValue, ex);
            }
        }
 public By GetElementLocator(How locator, string locatorValue)
 {
     switch (locator)
     {
         case How.XPath:
             return By.XPath(locatorValue);
         case How.ClassName:
             return By.ClassName(locatorValue);
         case How.CssSelector:
             return By.CssSelector(locatorValue);
         case How.LinkText:
             return By.LinkText(locatorValue);
         case How.Name:
             return By.Name(locatorValue);
         case How.PartialLinkText:
             return By.PartialLinkText(locatorValue);
         default:
             return By.Id(locatorValue);
     }
 }
Example #33
0
        public SimpleLocator(String Name, int Order, Scope Scope, How How, String Using, String ControlTypeName = null)
            : base(Name, Order, Scope)
        {
            _how = How;
            _usingValue = Using;
            _controlTypeName = ControlTypeName;
            _description = String.Format("Simple Locator: Order: {0} Scope: [{1}] How: [{2}] Using: [{3}] Control Type: [{4}]", Order, Scope, How.ToString(), Using, ControlTypeName == null ? "All" : ControlTypeName);

            switch (How)
            {
                case How.Class:
                    _condition = new PropertyCondition(AutomationElement.ClassNameProperty, _usingValue);
                    break;
                case How.AutomationId:
                    _condition = new PropertyCondition(AutomationElement.AutomationIdProperty, _usingValue);
                    break;
                case How.AutomationName:
                    _condition = new PropertyCondition(AutomationElement.NameProperty, _usingValue);
                    break;
            }

            if (!String.IsNullOrWhiteSpace(_controlTypeName))
            {

                var controlType = AutomationHelper.GetControlType(_controlTypeName);

                if (controlType == null)
                {

                    throw new InvalidControlTypeNameException(_controlTypeName);

                }
                else
                {

                    _condition = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, controlType), _condition);

                }

            }
        }
Example #34
0
 public static By From(How how, string usingStr)
 {
     switch (how)
     {
         case How.Id:
             return By.Id(usingStr);
         case How.Name:
             return By.Name(usingStr);
         case How.TagName:
             return By.TagName(usingStr);
         case How.ClassName:
             return By.ClassName(usingStr);
         case How.CssSelector:
             return By.CssSelector(usingStr);
         case How.LinkText:
             return By.LinkText(usingStr);
         case How.PartialLinkText:
             return By.PartialLinkText(usingStr);
         case How.XPath:
             return By.XPath(usingStr);
         default:
             throw new UnsupportedIdentityTypeException(string.Format("Unable to locate an Identity using locateor type: {0}", how));
     }
 }
Example #35
0
        /// <summary>
        /// Find Element By Using Common Property Conditions.
        /// </summary>
        /// <param name="Order">Specifies Order of Chained Look-Up, Does Not Have to be Sequential Or Start at 0 or Are Local to PlaceHolder.</param>
        /// <param name="How">Specifies the Method Used to Find Controls.</param>
        /// <param name="Using">Used as a Parameter to the Specified 'How' Method.</param>
        /// <param name="Scope">Scope of Search</param>
        /// <param name="ControlType">ControlType Specifies System.Windows.Automation.ControlType as String</param>
        public FindByAttribute(int Order, How How, String Using, Scope Scope = Scope.ChildrenOnly,
                               String ControlType = "")
        {
            _order = Order;

            _locator = new SimpleLocator(String.Empty, _order, Scope, How, Using, ControlType);
        }
Example #36
0
        /// <summary>
        /// Find UI Element By Using And/Or Property Condition KeyValue Pairs.
        /// </summary>
        /// <param name="Order">Specifies Order of Chained Look-Up, Does Not Have to be Sequential Or Start at 0 or Are Local to PlaceHolder.</param>
        /// <param name="How">Specifies the Method Used to Find Controls.</param>
        /// <param name="Scope">Scope of Search</param>
        /// <param name="PropertyValuePairs">Key Value Pairs. Equals: Property==Value or Property=Value. Not Equals: Property!=Value or Property&lt;&gt;Value.</param>
        public FindByAttribute(int Order, How How, Scope Scope = Scope.ChildrenOnly, params String[] PropertyValuePairs)
        {
            _order = Order;

            if (How == How.AndProperty)
            {
                _locator = new ChainedLocator(String.Empty, _order, Scope, ChainedLocator.ConditionType.And,
                                                PropertyValuePairs);
            }
            else if (How == How.OrProperty)
            {
                _locator = new ChainedLocator(String.Empty, _order, Scope, ChainedLocator.ConditionType.Or,
                                                PropertyValuePairs);
            }
            else
            {
                throw new ArgumentException("Invalid How, for Key Value Conditions How Must Equal And or Or!");
            }
        }