/// <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> /// Verifies the elements name or AutomationId based on the given compare. /// </summary> /// <param name="element"> /// The element to verify. /// </param> /// <param name="compare"> /// The value to verify is the name or AutomationId. /// </param> /// <returns> /// True if the element's name or AutomationId matches; otherwise, false. /// </returns> public static bool VerifyNameOrAutomationIdEquals(this AppiumWebElement element, string compare) { string name = element.GetAttribute("Name"); string automationId = element.GetAttribute("AutomationId"); return(string.Equals(compare, name, StringComparison.CurrentCultureIgnoreCase) || string.Equals( compare, automationId, StringComparison.CurrentCultureIgnoreCase)); }
public void ScrollToExactTestCase() { AppiumWebElement table = driver.FindElement(new ByIosUIAutomation(".tableViews()[0]")); AppiumWebElement slider = table.FindElement( new ByIosUIAutomation(".scrollToElementWithPredicate(\"name CONTAINS 'Slider'\")")); Assert.AreEqual(slider.GetAttribute("name"), "Sliders"); }
/// <summary> /// Sets the switch value to On / Off. /// </summary> /// <param name="bySelector">Selector for switch.</param> /// <param name="value">Value to be selected on switch.</param> public static void SetSwitchValue(By bySelector, eSwitchValue value) { AppiumWebElement switchElement = null; try { switchElement = FindElement(bySelector); string currentSwitchValue = switchElement.GetAttribute("value"); if ((value == eSwitchValue.Off && currentSwitchValue.Equals("1")) || (value == eSwitchValue.On && currentSwitchValue.Equals("0"))) { Click(switchElement); } } catch (Exception e) { PrintException(e); } }
public static string GetComboBoxValue(this AppiumWebElement element) { return(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? element.Text : element.GetAttribute("value")); }
public string GetPageTitle(AppiumWebElement Title) { return(Title.GetAttribute("Name")); }
public static string GetAutomationId(this AppiumWebElement element) { return(element.GetAttribute("AutomationId")); }
public static string GetName(this AppiumWebElement element) { return(element.GetAttribute("Name")); }