/// <summary> /// Finds the first element in the screen that matches the xPath criteria and then click it. /// </summary> /// <param name="text">text to match the element to be found</param> /// <param name="elem">Represents the Enum in Share class</param> /// <param name="widget">boolean if this is a widget</param> public static void ByXPath(string text, Share.Element elem = Share.Element.EditText, bool widget = true) { try { var elements = GetControl.CollectionByXPath(elem, widget); foreach (var element in elements) { if (element.Text.Contains(text)) { element.Click(); } } } catch (Exception ex) { Assert.Fail("ClickByXPath threw an exception: " + ex.Message); } }