protected override void EnterText(string elementID, string text, XamarinSelector xamarinSelector, TimeSpan timeout) { WaitForElement(elementID, xamarinSelector, timeout); switch (xamarinSelector) { case XamarinSelector.ByAutomationId: Application.Tap(x => x.Marked(elementID)); Application.ClearText(); Application.EnterText(x => x.Marked(elementID), text); break; case XamarinSelector.ByHtmlIdAttribute: Application.EnterText(QueryByHtmlElementValue(elementID), text); break; case XamarinSelector.ByHtmlValue: throw new InvalidOperationException("Test error - you can't input text in an html element that has a value"); default: throw new NotImplementedException("Invalid enum value " + xamarinSelector); } DismissKeyboard(); }
protected override void Tap(string elementID, XamarinSelector xamarinSelector, TimeSpan timeout) { switch (xamarinSelector) { case XamarinSelector.ByAutomationId: try { WaitForElement(elementID, xamarinSelector, timeout); Application.Tap(x => x.Marked(elementID)); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Failed waiting for element. Attempting to tap regardless..."); Application.Tap(x => x.Marked(elementID)); } break; case XamarinSelector.ByHtmlIdAttribute: WaitForElement(elementID, xamarinSelector, timeout); Application.Tap(QueryByCssId(elementID)); break; case XamarinSelector.ByHtmlValue: WaitForElement(elementID, xamarinSelector, timeout); Application.Tap(QueryByHtmlElementValue(elementID)); break; default: throw new NotImplementedException("Invalid enum value " + xamarinSelector); } }
public object[] WaitForElement(string selector, XamarinSelector xamarinSelector, TimeSpan?timeout) { if (timeout == null) { timeout = _defaultSearchTimeout; } switch (xamarinSelector) { case XamarinSelector.ByAutomationId: return(WaitForXamlElement(selector, timeout)); case XamarinSelector.ByHtmlIdAttribute: return(WaitForWebElementByCssId(selector, timeout)); case XamarinSelector.ByHtmlValue: return(WaitForWebElementByText(selector, timeout)); default: throw new NotImplementedException("Invalid enum value " + xamarinSelector); } }
protected override void Tap(string elementID, XamarinSelector xamarinSelector, TimeSpan timeout) { WaitForElement(elementID, xamarinSelector, timeout); switch (xamarinSelector) { case XamarinSelector.ByAutomationId: Application.Tap(x => x.Marked(elementID)); break; case XamarinSelector.ByHtmlIdAttribute: Application.Query(InvokeTapByCssId(elementID)); break; case XamarinSelector.ByHtmlValue: Application.Query(InvokeTapByHtmlElementValue(elementID)); break; default: throw new NotImplementedException("Invalid enum value " + xamarinSelector); } }
protected abstract void EnterText(string elementID, string text, XamarinSelector xamarinSelector, TimeSpan timeout);
public void EnterText(string elementID, int waitTime, string text, XamarinSelector xamarinSelector) { EnterText(elementID, text, xamarinSelector, new TimeSpan(0, 0, waitTime)); }
public void EnterText(string elementID, string text, XamarinSelector xamarinSelector) { EnterText(elementID, text, xamarinSelector, _defaultSearchTimeout); }
protected abstract void Tap(string elementID, XamarinSelector xamarinSelector, TimeSpan timeout);
public void Tap(string elementID, int waitTime, XamarinSelector xamarinSelector) { Tap(elementID, xamarinSelector, new TimeSpan(0, 0, waitTime)); }
public void Tap(string elementID, XamarinSelector xamarinSelector) { Tap(elementID, xamarinSelector, _defaultSearchTimeout); }