Element API
Please read the Material Usage Rules on this site.
Description
IAndroidElementAPI
This interface allows you to manage user interface elements in Android apps. You use it to perform various actions on elements found using the IAppiumDriverAPI interface methods.
Properties
- Element's id property value
string Id { get; }
- Element's text property value
string Text { get; }
Examples:
var driver = instance.DroidInstance.AppiumDriver;
var de = driver.FindElementByXPath("//*[@text=\"Display\"]"); // Find element by XPath
if (de == null)
throw new Exception("Element not found");
var id = de.Id; // Get the Id property value
var text = de.Text; // Get the text property value
Methods
Get an element's property value
string GetAttribute(string name)
Parameters:
string name // Name of the property you want to get.
Example
var driver = instance.DroidInstance.AppiumDriver;
var de = driver.FindElementByXPath("//*[@text=\"Display\"]"); // Find element by XPath
if (de == null)
throw new Exception("Element not found");
var bounds = de.GetAttribute("bounds"); // Get the "bounds" property value
var text = de.GetAttribute("text"); // Get the "text" property value
Click the found element
void Click()
Example
var driver = instance.DroidInstance.AppiumDriver;
var de = driver.FindElementByXPath("//*[@text=\"Display\"]"); // Find element by XPath
if (de == null)
throw new Exception("Element not found");
de.Click(); // Click on the element