/// <summary> /// Waits until the <see cref="AppDriver"/> is ready. /// </summary> /// <param name="appDriver"> /// The <see cref="AppDriver"/> on which to executor the command. /// </param> public static void WaitUntilReady(this AppDriver appDriver) { while (!appDriver.IsReady()) { Thread.Sleep(1000); } }
/// <summary> /// Dismisses the the keyboard. /// </summary> /// <param name="appDriver"> /// The <see cref="AppDriver"/> on which to executor the command. /// </param> public static void DismissKeyboard(this AppDriver appDriver) { appDriver.ExecuteCommand(AppDriverCommand.DismissKeyboard, new Dictionary <string, object>() { { AppDriverCommand.SessionId, appDriver.SessionId } }); }
/// <summary> /// Clears the text of the active text field. /// </summary> /// <param name="appDriver"> /// The <see cref="AppDriver"/> on which to executor the command. /// </param> public static void ClearText(this AppDriver appDriver) { appDriver.ExecuteCommand(AppDriverCommand.ClearText, new Dictionary <string, object>() { { AppDriverCommand.SessionId, appDriver.SessionId } }); }
/// <summary> /// Executes a command on the given <see cref="AppDriver"/> /// </summary> /// <param name="appDriver"> /// The <see cref="AppDriver"/> on which to executor the command. /// </param> /// <param name="name"> /// The name of the command. /// </param> /// <param name="parameters"> /// The parameters of the command. /// </param> /// <returns> /// The response of the execution. /// </returns> private static Response ExecuteCommand(this AppDriver appDriver, string name, Dictionary <string, object> parameters) { var command = new Command(appDriver.SessionId, name, parameters); var response = appDriver.GetCommandExecutor().Execute(command); return(response); }
/// <summary> /// Executes a command on the given <see cref="AppDriver"/> /// </summary> /// <param name="appDriver"> /// The <see cref="AppDriver"/> on which to executor the command. /// </param> /// <param name="name"> /// The name of the command. /// </param> /// <param name="jsonParameters"> /// The parameters of the command. /// </param> /// <returns> /// The response of the execution. /// </returns> private static Response ExecuteCommand(this AppDriver appDriver, string name, string jsonParameters) { var command = new Command(name, jsonParameters); var response = appDriver.GetCommandExecutor().Execute(command); return(response); }
public static Timeouts GetTimeouts(this AppDriver appDriver) { var response = appDriver.ExecuteCommand(AppDriverCommand.GetTimeouts, new Dictionary <string, object>() { { AppDriverCommand.SessionId, appDriver.SessionId } }); return(GetValue <Timeouts>(response)); }
/// <summary> /// Clicks on the device screen on the given absolute coordinate. /// </summary> /// <param name="appDriver"> /// The <see cref="AppDriver"/> on which to execute the command. /// </param> /// <param name="x"> /// The x component of the coordinate. /// </param> /// <param name="y"> /// The y component of the coordinate. /// </param> public static void ClickByCoordinate(this AppDriver appDriver, int x, int y) { appDriver.ExecuteCommand(AppDriverCommand.ClickByCoordinate, new Dictionary <string, object>() { { AppDriverCommand.SessionId, appDriver.SessionId }, { "x", x }, { "y", y } }); }
public static void Flick(this AppDriver appDriver, IWebElement element, Direction direction) { var remoteWebElementType = typeof(RemoteWebElement); var elementIdField = remoteWebElementType.GetField("elementId", BindingFlags.Instance | BindingFlags.NonPublic); var elementId = elementIdField.GetValue(element) as string; appDriver.ExecuteCommand(AppDriverCommand.FlickCoordinate, new Dictionary <string, object>() { { "element", elementId }, { "direction", direction } }); }
public static void ScrollToVisible(this AppDriver appDriver, IWebElement element) { var remoteWebElementType = typeof(RemoteWebElement); var elementIdField = remoteWebElementType.GetField("elementId", BindingFlags.Instance | BindingFlags.NonPublic); var elementId = elementIdField.GetValue(element) as string; appDriver.ExecuteCommand(AppDriverCommand.ScrollToVisible, new Dictionary <string, object>() { { AppDriverCommand.SessionId, appDriver.SessionId }, { AppDriverCommand.ElementId, elementId }, }); }
public static object PerformOperation(this AppDriver appDriver, IWebElement webElement, string operation, Collection <object> arguments) { var remoteWebElementType = typeof(RemoteWebElement); var elementIdField = remoteWebElementType.GetField("elementId", BindingFlags.Instance | BindingFlags.NonPublic); var elementId = elementIdField.GetValue(webElement) as string; return(appDriver.ExecuteCommand(AppDriverCommand.PerformOperation, new Dictionary <string, object> { { AppDriverCommand.SessionId, appDriver.SessionId }, { AppDriverCommand.ElementId, elementId }, { "operation", operation }, { "args", arguments } }).Value); }
public static void SetProperty(this AppDriver appDriver, IWebElement element, string name, string value) { var remoteWebElementType = typeof(RemoteWebElement); var elementIdField = remoteWebElementType.GetField("elementId", BindingFlags.Instance | BindingFlags.NonPublic); var elementId = elementIdField.GetValue(element) as string; appDriver.ExecuteCommand(AppDriverCommand.SetProperty, new Dictionary <string, object>() { { AppDriverCommand.SessionId, appDriver.SessionId }, { AppDriverCommand.ElementId, elementId }, { AppDriverCommand.PropertyName, name }, { AppDriverCommand.PropertyValue, value }, }); }
/// <summary> /// Scrolls until an element with the marked contition is visible. /// </summary> /// <param name="appDriver"> /// The <see cref="AppDriver"/> on which to executor the command. /// </param> /// <param name="element"> /// The element on which to swipe. /// </param> /// <param name="xpath"> /// the xpath condition to stop scrolling. /// </param> public static void ScrollUpTo(this AppDriver appDriver, IWebElement element, string xpath) { var remoteWebElementType = typeof(RemoteWebElement); var elementIdField = remoteWebElementType.GetField("elementId", BindingFlags.Instance | BindingFlags.NonPublic); var elementId = elementIdField.GetValue(element) as string; appDriver.ExecuteCommand(AppDriverCommand.ScrollTo, new Dictionary <string, object>() { { AppDriverCommand.SessionId, appDriver.SessionId }, { AppDriverCommand.ElementId, elementId }, { "value", xpath }, { "using", "xpath" }, { "direction", "Down" } }); }
public static void FlickCoordinate(this AppDriver appDriver, IWebElement element, int x, int y, int xOffset, int yOffset, int speed) { var remoteWebElementType = typeof(RemoteWebElement); var elementIdField = remoteWebElementType.GetField("elementId", BindingFlags.Instance | BindingFlags.NonPublic); var elementId = elementIdField.GetValue(element) as string; appDriver.ExecuteCommand(AppDriverCommand.FlickCoordinate, new Dictionary <string, object>() { { "element", elementId }, { "xCoordinate", x }, { "yCoordinate", y }, { "xoffset", xOffset }, { "yoffset", yOffset }, { "speed", speed }, }); }
public static string GetDeviceId(this AppDriver appDriver) { var capabilities = appDriver.Capabilities as ICapabilities; return(capabilities?.GetCapability("deviceId").ToString()); }
/// <summary> /// Checks if the <see cref="AppDriver"/> is ready. /// </summary> /// <param name="appDriver"> /// The <see cref="AppDriver"/> on which to executor the command. /// </param> /// <returns> /// <see langword="true"/> if the <see cref="AppDriver"/> is ready; /// otherwise, returns <see langword="false"/> /// </returns> public static bool IsReady(this AppDriver appDriver) { var response = appDriver.ExecuteCommand(AppDriverCommand.IsReady, new Dictionary <string, object>()); return((bool)response.Value); }
public static bool TestElementsByClassChain(this AppDriver appDriver, string value) { return(appDriver.TestElements(AppDriver.ClassChain, value)); }
public static bool TestElementsByPredicateString(this AppDriver appDriver, string value) { return(appDriver.TestElements(AppDriver.PredicateString, value)); }
public static ReadOnlyCollection <IWebElement> FindElementsByClassChain(this AppDriver appDriver, string value) { return(appDriver.FindElements(AppDriver.ClassChain, value)); }
public static IWebElement FindElementByClassChain(this AppDriver appDriver, string value) { return(appDriver.FindElement(AppDriver.ClassChain, value)); }
public static ReadOnlyCollection <IWebElement> FindElementsByPredicateString(this AppDriver appDriver, string value) { return(appDriver.FindElements(AppDriver.PredicateString, value)); }
public static IWebElement FindElementByPredicateString(this AppDriver appDriver, string value) { return(appDriver.FindElement(AppDriver.PredicateString, value)); }
/// <summary> /// Executes a command on the given <see cref="AppDriver"/> /// </summary> /// <typeparam name="T"> /// The response type /// </typeparam> /// <param name="appDriver"> /// The <see cref="AppDriver"/> on which to executor the command. /// </param> /// <param name="name"> /// The name of the command. /// </param> /// <param name="parameters"> /// The parameters of the command. /// </param> /// <returns> /// The response of the execution. /// </returns> private static T ExecuteCommand <T>(this AppDriver appDriver, string name, Dictionary <string, object> parameters) { var command = new Command(appDriver.SessionId, name, parameters); return(appDriver.GetCommandExecutor().Execute <T>(command)); }
/// <summary> /// Finds an element based on the marked meta tag. An element corresponds to the marked meta tag if the text property or the element id equals the tag value. /// </summary> /// <param name="appDriver"> /// The <see cref="AppDriver"/> on which to executor the command. /// </param> /// <param name="marked"> /// The marked meta tag. /// </param> /// <returns> /// The element matching the marked meta tag. /// </returns> public static IWebElement FindElementByMarked(this AppDriver appDriver, string marked) { return(appDriver.FindElement(By.XPath($"*[@marked='{marked}']"))); }
/// <summary> /// Executes a command on the given <see cref="AppDriver"/> /// </summary> /// <typeparam name="T"> /// The response type /// </typeparam> /// <param name="appDriver"> /// The <see cref="AppDriver"/> on which to executor the command. /// </param> /// <param name="name"> /// The name of the command. /// </param> /// <param name="jsonParameters"> /// The parameters of the command. /// </param> /// <returns> /// The response of the execution. /// </returns> private static T ExecuteCommand <T>(this AppDriver appDriver, string name, string jsonParameters) { var command = new Command(name, jsonParameters); return(appDriver.GetCommandExecutor().Execute <T>(command)); }
/// <summary> /// Gets the <c>WebDriver</c> status /// </summary> /// <param name="appDriver"> /// The <see cref="AppDriver"/> on which to executor the command. /// </param> /// <returns> /// The <c>WebDriver</c> status /// </returns> public static Status GetStatus(this AppDriver appDriver) { var response = appDriver.ExecuteCommand(AppDriverCommand.GetStatus, string.Empty); return(GetValue <Status>(response)); }