Esempio n. 1
0
        public void UpdateWebElementWithAdditionalProperties(WebElementDefinition element)
        {
            var by         = WebSpyBrowser.ConvertLocatorSearchMethodToBy(element.HowToSearch, element.Locator);
            var attributes = new Dictionary <string, string>();

            try
            {
                attributes = WebSpyBrowser.ReadElementAttributes(by);
            }
            catch (Exception e)
            {
                string errorMsg = string.Format(
                    "UpdateWebElementWithAdditionalProperties:\n" +
                    "Failed to find element: How={0};   Locator={1}\n" +
                    "With exception:\n {2}"
                    , element.HowToSearch.ToString()
                    , element.Locator.ToString()
                    , e.Message

                    );
                MyLog.Error(errorMsg);
            }


            if (attributes.Count == 0)
            {
                return;
            }

            element.HtmlTag = attributes["TagName"];
            attributes.Remove("TagName");

            WebElementHtmlAttributes elementAttrs = new WebElementHtmlAttributes();

            foreach (var attrKey in attributes.Keys)
            {
                elementAttrs.Add(attrKey, attributes[attrKey]);
            }

            element.AllHtmlTagProperties = elementAttrs;
        }