Пример #1
0
        public DataTable GetTableElement(CiscoWebExCommandArguments search, TimeSpan timeout)
        {
            var element = GetElementInFrame(search, timeout);

            if (element == null)
            {
                throw new Exception("Cannot find the HTML element. Try to change the search phrase or \"by\" argument value so that the correct element is found");
            }
            else if (element.TagName != "table")
            {
                throw new Exception($"The element found has the \"{element.TagName}\" tag name. Try to change the search phrase so that the \"table\" element is found instead");
            }

            var dataTable  = new DataTable();
            var trElements = element.FindElements(By.TagName("tr"));

            dataTable = AddColumnNamesFromThElements(dataTable, trElements[0].FindElements(By.TagName("th")));

            foreach (var trElement in trElements)
            {
                var tdElements = trElement.FindElements(By.TagName("td"));
                dataTable = AddColumnsIfThereAreMoreTdElements(dataTable, tdElements.Count);
                dataTable = AddRowToDataTable(dataTable, tdElements);
            }

            return(dataTable);
        }
Пример #2
0
        public void TypeText(string text, CiscoWebExCommandArguments search, TimeSpan timeout)
        {
            var elem = GetElementInFrame(search, timeout);

            elem.SendKeys(text);
            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().DefaultContent();
            }
        }
Пример #3
0
        private IWebElement GetElementInFrame(CiscoWebExCommandArguments search, TimeSpan timeout)
        {
            PreCheckCurrentWindowHandle();
            if (!string.IsNullOrEmpty(search.IFrameSearch?.Value))
            {
                webDriver.SwitchTo().Frame(FindElement(search.IFrameSearch.Value, search.IFrameBy.Value, timeout));
            }
            var element = FindElement(search.Search.Value, search.By.Value, timeout);

            return(element);
        }
Пример #4
0
        public string GetTextValue(CiscoWebExCommandArguments search, TimeSpan timeout)
        {
            var element = GetElementInFrame(search, timeout);

            var res = element?.Text ?? string.Empty;

            if (!string.IsNullOrEmpty(search.IFrameSearch?.Value))
            {
                webDriver.SwitchTo().DefaultContent();
            }
            return(res);
        }
Пример #5
0
        public string GetAttributeValue(string attributeName, CiscoWebExCommandArguments search)
        {
            var element = GetElementInFrame(search, search.Timeout.Value);

            var result = element?.GetAttribute(attributeName);

            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().DefaultContent();
            }

            return(result ?? string.Empty);
        }
Пример #6
0
        public void Click(CiscoWebExCommandArguments search, TimeSpan timeout, bool waitForNewWindow = false)
        {
            NewPopupWindowHandler popupHandler = new NewPopupWindowHandler(webDriver);
            var     elem    = GetElementInFrame(search, timeout);
            Actions actions = new Actions(webDriver);

            actions.MoveToElement(elem).Click().Build().Perform();
            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().DefaultContent();
            }
            popupHandler.Finish(waitForNewWindow, timeout);
        }
Пример #7
0
        public void PressKey(string keyText, CiscoWebExCommandArguments search, TimeSpan timeout)
        {
            NewPopupWindowHandler popupHandler = new NewPopupWindowHandler(webDriver);
            var    elem          = GetElementInFrame(search, timeout);
            string convertedText = typeof(Keys).GetFields().Where(x => x.Name.ToLower() == keyText.ToLower()).FirstOrDefault()?.GetValue(null) as string;

            if (convertedText == null)
            {
                throw new ArgumentException($"Wrong key argument '{keyText}' specified. Please use keys allowed by selenium library.");
            }
            elem.SendKeys(convertedText);
            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().DefaultContent();
            }
            popupHandler.Finish();
        }
Пример #8
0
        public void CallFunction(string functionName, object[] arguments, string type, CiscoWebExCommandArguments search, TimeSpan timeout)
        {
            NewPopupWindowHandler popupHandler = new NewPopupWindowHandler(webDriver);

            PreCheckCurrentWindowHandle();
            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().Frame(FindElement(search.IFrameSearch.Value, search.IFrameBy.Value, timeout));
            }
            IWebElement element = FindElement(search.Search.Value, search.By.Value, timeout);

            element?.CallFunction(functionName, arguments, type);
            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().DefaultContent();
            }
            popupHandler.Finish();
        }
Пример #9
0
 public string GetOuterHtml(CiscoWebExCommandArguments search)
 {
     return(GetAttributeValue("outerHTML", search));
 }
Пример #10
0
        public void SetAttributeValue(string attributeName, string attributeValue, AttributeOperationType setAttributeType, CiscoWebExCommandArguments search, TimeSpan timeout)
        {
            var element = GetElementInFrame(search, timeout);

            if (element != null)
            {
                if (IsAttributeOprtationType(element, attributeName, setAttributeType))
                {
                    element.SetAttribute(attributeName, attributeValue);
                }
                else
                {
                    element.SetProperty(attributeName, attributeValue);
                }
            }
            if (string.IsNullOrEmpty(search.IFrameSearch?.Value) == false)
            {
                webDriver.SwitchTo().DefaultContent();
            }
        }