Ejemplo n.º 1
0
        public IWebControl FindElementBy(FindByType criteria, string textCriteria, Type type, WaitingConditionType waitCondition, int timeoutInSeconds = 90)
        {
            if (waitCondition == WaitingConditionType.NoWait)
            {
                return(FindElementBy(criteria, textCriteria, type));
            }

            IWebControl control = null;
            IWebElement element = null;

            try
            {
                element = GetWebElement(criteria, textCriteria, waitCondition, timeoutInSeconds);
                control = GetWebControl(criteria, type, element);

                return(control);
            }
            catch (TypeNotSupportedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new ElementNotFoundException("No element found by textcriteria =" + textCriteria, ex);
            }
        }
Ejemplo n.º 2
0
 public FindByAttribute(FindByType criteria, WaitCondition condition)
 {
     Criteria          = criteria;
     TextCriteria      = condition.TextContained;
     WaitConditionType = condition.WaitingConditionType;
     Timeout           = condition.Timeout;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a FindInfo object initialized by the given parameters.
        /// </summary>
        /// <param name="parentFolder">List children of this folder.</param>
        /// <param name="inclFolders">Include child folders.</param>
        /// <param name="inclDocs">Include child documents.</param>
        /// <returns></returns>
        protected static FindInfo makeFindInfo(FWFolder parentFolder, bool inclFolders, bool inclDocs)
        {
            FindInfo     fi = new FindInfo();
            FindChildren fc = new FindChildren();

            fc.parentId     = Convert.ToString(parentFolder.Id);
            fi.findChildren = fc;

            if (inclFolders && inclDocs)
            {
                // do not need to constrain
            }
            else //(inclFolders || inclDocs)
            {
                FindByType ft = new FindByType();
                ft.typeStructures = inclFolders;
                ft.typeDocuments  = inclDocs;
                fi.findByType     = ft;
            }

            //FindOptions fo = new FindOptions();
            //fo.sortOrder = SortOrderC.NONE;
            //fi.findOptions = fo;

            return(fi);
        }
Ejemplo n.º 4
0
        public static List <Sord> FindChildren(String objId, IXConnection ixConn, bool references)
        {
            Console.WriteLine("FindChildren: objId " + objId, " ixConn " + ixConn);
            try
            {
                ixConn.Ix.checkoutSord(objId, SordC.mbAll, LockC.NO);
            }
            catch (Exception)
            {
                return(new List <Sord>());
            }

            List <Sord>  children          = new List <Sord>();
            FindInfo     findInfo          = new FindInfo();
            FindChildren findChildren      = new FindChildren();
            FindByType   findByType        = new FindByType();
            FindByIndex  findByIndex       = new FindByIndex();
            Boolean      includeReferences = references;
            SordZ        sordZ             = SordC.mbAll;
            Boolean      recursive         = true;
            int          level             = 3;

            ObjKey[] objKeys = new ObjKey[] { };
            findChildren.parentId   = objId;
            findChildren.mainParent = !includeReferences;
            findChildren.endLevel   = (recursive) ? level : 1;
            findInfo.findChildren   = findChildren;
            findInfo.findByIndex    = findByIndex;

            FindResult findResult = new FindResult();

            try
            {
                int idx = 0;
                findResult = ixConn.Ix.findFirstSords(findInfo, 1000, sordZ);
                while (true)
                {
                    for (int i = 0; i < findResult.sords.Length; i++)
                    {
                        children.Add(findResult.sords[i]);
                    }
                    if (!findResult.moreResults)
                    {
                        break;
                    }
                    idx       += findResult.sords.Length;
                    findResult = ixConn.Ix.findNextSords(findResult.searchId, idx, 1000, sordZ);
                }
            }
            finally
            {
                if (findResult != null)
                {
                    ixConn.Ix.findClose(findResult.searchId);
                }
            }
            return(children);
        }
Ejemplo n.º 5
0
        private IWebElement GetWebElement(FindByType criteria, string textCriteria, WaitingConditionType waitCondition,
                                          int timeoutInSeconds)
        {
            IWebElement element = null;

            if (timeoutInSeconds < 1)
            {
                timeoutInSeconds = 1;
            }

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));

            switch (criteria)
            {
            case FindByType.ById:
            {
                element = GetElement(wait, waitCondition, By.Id(textCriteria));
                break;
            }

            case FindByType.ByName:
            {
                element = GetElement(wait, waitCondition, By.Name(textCriteria));
                break;
            }

            case FindByType.ByClassName:
            {
                element = GetElement(wait, waitCondition, By.ClassName(textCriteria));
                break;
            }

            case FindByType.ByCssSelector:
            {
                element = GetElement(wait, waitCondition, By.CssSelector(textCriteria));
                break;
            }

            case FindByType.ByXPath:
            {
                element = GetElement(wait, waitCondition, By.XPath(textCriteria));
                break;
            }
            }
            return(element);
        }
Ejemplo n.º 6
0
        private static IWebControl GetWebControl(FindByType criteria, Type type, IWebElement element)
        {
            IWebControl control;

            if (element == null)
            {
                throw new CriteriaNotSupportedException("Criteria " + criteria + " is not supported");
            }

            if (type == typeof(ITextBox))
            {
                control = new SeleniumTextBox(element);
            }
            else if (type == typeof(IButton))
            {
                control = new SeleniumButton(element);
            }
            else if (type == typeof(IDropDownList))
            {
                control = new SeleniumDropDownList(element);
            }
            else if (type == typeof(IInputButton))
            {
                control = new SeleniumInputButton(element);
            }
            else if (type == typeof(ILabel))
            {
                control = new SeleniumLabel(element);
            }
            else if (type == typeof(ILink))
            {
                control = new SeleniumLink(element);
            }
            else if (type == typeof(IWebControl))
            {
                control = new SeleniumBaseControl(element);
            }
            else
            {
                throw new TypeNotSupportedException("Type " + type.ToString() + " is not supported");
            }
            return(control);
        }
Ejemplo n.º 7
0
        public IWebControl FindElementBy(FindByType criteria, string textCriteria, Type type)
        {
            IWebControl control = null;
            IWebElement element = null;

            try
            {
                element = GetWebElement(criteria, textCriteria);
                control = GetWebControl(criteria, type, element);
                return(control);
            }
            catch (TypeNotSupportedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new ElementNotFoundException("No element found by textcriteria =" + textCriteria, ex);
            }
        }
Ejemplo n.º 8
0
        private IWebElement GetWebElement(FindByType criteria, string textCriteria)
        {
            IWebElement element = null;

            switch (criteria)
            {
            case FindByType.ById:
            {
                element = driver.FindElementById(textCriteria);
                break;
            }

            case FindByType.ByName:
            {
                element = driver.FindElementByName(textCriteria);
                break;
            }

            case FindByType.ByClassName:
            {
                element = driver.FindElementByClassName(textCriteria);
                break;
            }

            case FindByType.ByCssSelector:
            {
                element = driver.FindElementByCssSelector(textCriteria);
                break;
            }

            case FindByType.ByXPath:
            {
                element = driver.FindElementByXPath(textCriteria);
                break;
            }
            }
            return(element);
        }
Ejemplo n.º 9
0
 public IWebControl GetElementBy(FindByType criteria, string textCriteria, Type type, WaitingConditionType waitCondition = WaitingConditionType.NoWait)
 {
     return(Manager.FindElementBy(criteria, textCriteria, type, waitCondition));
 }
Ejemplo n.º 10
0
        public static bool WaitForElementReady(IWebDriver driver, string findElement, FindByType findByType = FindByType.Id, int sleepMilleseconds = 500, int waitSeconds = 30)
        {
            Thread.Sleep(sleepMilleseconds);
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitSeconds));

            return(wait.Until <bool>((d) =>
            {
                switch (findByType)
                {
                case FindByType.XPath:
                    return driver.FindElement(By.XPath("" + findElement + "")).Displayed;

                case FindByType.CSSSelector:
                    return driver.FindElement(By.CssSelector("" + findElement + "")).Displayed;

                default:
                    return driver.FindElement(By.Id("" + findElement + "")).Displayed;
                }
            }));
        }
Ejemplo n.º 11
0
 public IWebControl FindElementBy(FindByType criteria, string textCriteria, Type type, WaitCondition waitCondition)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 12
0
 public void WaitControl(FindByType criteria, string textCriteria, WaitCondition condition)
 {
 }
Ejemplo n.º 13
0
        public IWebControl FindElementBy(FindByType criteria, string textCriteria, Type type, WaitingConditionType waitCondition = WaitingConditionType.NoWait, int timeoutInSeconds = 90)
        {
            activeBrowser.RefreshDomTree();
            if (waitCondition == WaitingConditionType.NoWait)
            {
                return(FindElementBy(criteria, textCriteria, type));
            }

            IWebControl control = null;
            Element     element = null;

            if (timeoutInSeconds < 1)
            {
                timeoutInSeconds = 1;
            }

            try
            {
                switch (criteria)
                {
                case FindByType.ById:
                {
                    if (waitCondition == WaitingConditionType.UntilElementIsExists)
                    {
                        activeBrowser.Find.ById(textCriteria).Wait.ForExists(timeoutInSeconds * 1000);
                    }
                    else
                    {
                        activeBrowser.Find.ById <HtmlControl>(textCriteria).Wait.ForVisible(timeoutInSeconds * 1000);
                    }
                    element = activeBrowser.Find.ById(textCriteria);
                    break;
                }

                case FindByType.ByName:
                {
                    if (waitCondition == WaitingConditionType.UntilElementIsExists)
                    {
                        activeBrowser.Find.ByName(textCriteria).Wait.ForExists(timeoutInSeconds * 1000);
                    }
                    else
                    {
                        activeBrowser.Find.ByName <HtmlControl>(textCriteria).Wait.ForVisible(timeoutInSeconds * 1000);
                    }
                    element = activeBrowser.Find.ByName(textCriteria);
                    break;
                }

                case FindByType.ByClassName:
                {
                    if (waitCondition == WaitingConditionType.UntilElementIsExists)
                    {
                        activeBrowser.Find.ByAttributes("class=~" + textCriteria).Wait.ForExists(timeoutInSeconds * 1000);
                    }
                    else
                    {
                        activeBrowser.Find.ByAttributes <HtmlControl>("class=~" + textCriteria).Wait.ForVisible(timeoutInSeconds * 1000);
                    }
                    element = activeBrowser.Find.ByAttributes("class=~" + textCriteria);
                    break;
                }

                case FindByType.ByCssSelector:
                {
                    string[] result;
                    string[] stringSeparators = new string[] { "." };
                    result = textCriteria.Split(stringSeparators, StringSplitOptions.None);
                    activeBrowser.Find.ByExpression("class=" + result[1], "tagname=" + result[0]).Wait.ForExists(timeoutInSeconds * 1000);
                    element = activeBrowser.Find.ByExpression("class=" + result[1], "tagname=" + result[0]);
                    break;
                }

                case FindByType.ByXPath:
                {
                    if (waitCondition == WaitingConditionType.UntilElementIsExists)
                    {
                        activeBrowser.Find.ByXPath(textCriteria).Wait.ForExists(timeoutInSeconds * 1000);
                    }
                    else
                    {
                        activeBrowser.Find.ByXPath <HtmlControl>(textCriteria).Wait.ForVisible(timeoutInSeconds * 1000);
                    }

                    element = activeBrowser.Find.ByXPath(textCriteria);
                    break;
                }
                }

                if (element == null)
                {
                    throw new CriteriaNotSupportedException("Criteria " + criteria + " is not supported");
                }


                if (type == typeof(ITextBox))
                {
                    control = new TelerikTextBox(element);
                }
                else if (type == typeof(IButton))
                {
                    control = new TelerikButton(element);
                }
                else if (type == typeof(IDropDownList))
                {
                    control = new TelerikDropDownList(element);
                }
                else if (type == typeof(IInputButton))
                {
                    control = new TelerikInputButton(element);
                }
                else if (type == typeof(ILabel))
                {
                    control = new TelerikLabel(element);
                }
                else if (type == typeof(IWebControl))
                {
                    control = new TelerikBaseControl(element);
                }
                else
                {
                    throw new TypeNotSupportedException("Type " + type.ToString() + " is not supported");
                }

                return(control);
            }
            catch (TypeNotSupportedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new ElementNotFoundException("No element found by textcriteria =" + textCriteria, ex);
            }
        }
Ejemplo n.º 14
0
        public IWebControl FindElementBy(FindByType criteria, string textCriteria, Type type)
        {
            IWebControl control = null;
            Element     element = null;

            try
            {
                activeBrowser.RefreshDomTree();
                activeBrowser.WaitUntilReady();
                switch (criteria)
                {
                case FindByType.ById:
                {
                    element = activeBrowser.Find.ById(textCriteria);
                    break;
                }

                case FindByType.ByName:
                {
                    element = activeBrowser.Find.ByName(textCriteria);
                    break;
                }

                case FindByType.ByClassName:
                {
                    element = activeBrowser.Find.ByAttributes("class=~" + textCriteria);
                    break;
                }

                case FindByType.ByCssSelector:
                {
                    string[] result;
                    string[] stringSeparators = new string[] { "." };
                    result  = textCriteria.Split(stringSeparators, StringSplitOptions.None);
                    element = activeBrowser.Find.ByExpression("class=" + result[1], "tagname=" + result[0]);
                    break;
                }

                case FindByType.ByXPath:
                {
                    element = activeBrowser.Find.ByXPath(textCriteria);
                    break;
                }
                }

                if (element == null)
                {
                    throw new CriteriaNotSupportedException("Criteria " + criteria + " is not supported");
                }

                if (type == typeof(ITextBox))
                {
                    control = new TelerikTextBox(element);
                }
                else if (type == typeof(IButton))
                {
                    control = new TelerikButton(element);
                }
                else if (type == typeof(IDropDownList))
                {
                    control = new TelerikDropDownList(element);
                }
                else if (type == typeof(ILabel))
                {
                    control = new TelerikLabel(element);
                }
                else if (type == typeof(IInputButton))
                {
                    control = new TelerikInputButton(element);
                }
                else if (type == typeof(IWebControl))
                {
                    control = new TelerikBaseControl(element);
                }
                else
                {
                    throw new TypeNotSupportedException("Type " + type.ToString() + " is not supported");
                }

                return(control);
            }
            catch (TypeNotSupportedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new ElementNotFoundException("No element found by textcriteria =" + textCriteria, ex);
            }
        }
Ejemplo n.º 15
0
 internal static List <ELCFolder> FindELCFolder(IConfigurationSession session, object valueToSearch, FindByType findByType)
 {
     return(ELCTaskHelper.FindELCFolder(session, null, valueToSearch, findByType));
 }
Ejemplo n.º 16
0
        internal static List <ELCFolder> FindELCFolder(IConfigurationSession session, ADObjectId rootId, object valueToSearch, FindByType findByType)
        {
            QueryFilter filter;

            switch (findByType)
            {
            case FindByType.Name:
                filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, (string)valueToSearch);
                goto IL_D4;

            case FindByType.FolderName:
                filter = new OrFilter(new QueryFilter[]
                {
                    new ComparisonFilter(ComparisonOperator.Equal, ELCFolderSchema.FolderName, (string)valueToSearch),
                    new TextFilter(ELCFolderSchema.LocalizedFolderName, (string)valueToSearch, MatchOptions.SubString, MatchFlags.IgnoreCase)
                });
                goto IL_D4;

            case FindByType.FolderType:
                filter = new ComparisonFilter(ComparisonOperator.Equal, ELCFolderSchema.FolderType, (ElcFolderType)valueToSearch);
                goto IL_D4;

            case FindByType.FolderAdObjectId:
                filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, valueToSearch as ADObjectId);
                goto IL_D4;

            case FindByType.FolderDefaultType:
                filter = new ComparisonFilter(ComparisonOperator.NotEqual, ELCFolderSchema.FolderType, ElcFolderType.ManagedCustomFolder);
                goto IL_D4;

            case FindByType.FolderOrganizationalType:
                filter = new ComparisonFilter(ComparisonOperator.Equal, ELCFolderSchema.FolderType, ElcFolderType.ManagedCustomFolder);
                goto IL_D4;
            }
            filter = null;
IL_D4:
            return(ELCTaskHelper.FindElcObject <ELCFolder>(session, rootId, filter));
        }
Ejemplo n.º 17
0
 public void WaitControl(FindByType criteria, string textCriteria, WaitCondition condition)
 {
     var element = GetWebElement(criteria, textCriteria, condition.WaitingConditionType, condition.Timeout);
     //control = GetWebControl(criteria, type, element);
     //return element;
 }
Ejemplo n.º 18
0
 private IWebControl GetElementBy(FindByType criteria, string textCriteria, Type type, WaitingConditionType waitCondition = WaitingConditionType.NoWait)
 {
     return(page.GetElementBy(criteria, textCriteria, type, waitCondition));
 }
Ejemplo n.º 19
0
 public FindByAttribute(FindByType criteria, string textCriteria, WaitingConditionType waitConditiontype = WaitingConditionType.NoWait)
 {
     Criteria          = criteria;
     TextCriteria      = textCriteria;
     WaitConditionType = waitConditiontype;
 }