/// <summary> /// Gets the attribute value for an AppiumWebElement. /// </summary> /// <returns>The attribute value.</returns> /// <param name="element">Element.</param> /// <param name="attribute">Attribute.</param> public static string GetAttributeValue(AppiumWebElement element, eGUIElementAttribute attribute) { string attributeVal = string.Empty; switch (attribute) { case eGUIElementAttribute.Name: attributeVal = element.GetAttribute("name"); break; case eGUIElementAttribute.Label: attributeVal = element.GetAttribute("label"); break; case eGUIElementAttribute.Value: attributeVal = element.GetAttribute("value"); break; case eGUIElementAttribute.Displayed: attributeVal = element.Displayed.ToString().ToLower(); break; case eGUIElementAttribute.Enabled: attributeVal = element.Enabled.ToString().ToLower(); break; default: Console.WriteLine("Unknonwn attribute : " + attribute.ToString()); break; } return(attributeVal); }
/// <summary> /// This method gets the XPath attribute filter text. /// </summary> /// <returns>The XPath attribute filter text.</returns> /// <param name="attributeType">Attribute type.</param> /// <param name="attributeVal">Attribute value.</param> public static string GetXPathAttributeFilterText(eGUIElementAttribute attributeType, string attributeVal) { string xpathAttributeFilterText = string.Empty; switch (attributeType) { case eGUIElementAttribute.Label: xpathAttributeFilterText = "[@label='" + attributeVal + "']"; break; case eGUIElementAttribute.Name: xpathAttributeFilterText = "[@name='" + attributeVal + "']"; break; case eGUIElementAttribute.None: //No filter applied. break; default: Console.WriteLine("ERROR: Unknown attributeType: " + attributeType.ToString()); break; } return(xpathAttributeFilterText); }