public static void SetClipboard(IExecuteMethod executeMethod, ClipboardContentType clipboardContentType, string base64Content) { switch (clipboardContentType) { case ClipboardContentType.Image: case ClipboardContentType.Url: if (executeMethod.GetType().GetGenericTypeDefinition() == typeof(AndroidDriver <>)) { throw new NotImplementedException( $"Android only supports contentType: {nameof(ClipboardContentType.PlainText)}"); } executeMethod.Execute(AppiumDriverCommand.SetClipboard, PrepareArguments(new[] { "content", "contentType", "label" }, new object[] { base64Content, clipboardContentType.ToString().ToLower(), null })); break; default: executeMethod.Execute(AppiumDriverCommand.SetClipboard, PrepareArguments(new[] { "content", "contentType", "label" }, new object[] { base64Content, clipboardContentType.ToString().ToLower(), null })); break; } }
public static void SetAttribute(IExecuteMethod executeMethod, string elementId, string name, string value) { Dictionary <string, object> parameters = new Dictionary <string, object>(); string setAttributeScript = "this.setAttribute('" + name + "','" + value + "'," + elementId + " );"; parameters.Add("script", setAttributeScript); parameters.Add("args", elementId); executeMethod.Execute(DriverCommand.ExecuteScript, parameters); }
public static string SetClipboardText(IExecuteMethod executeMethod, string textContent, string label) { if (textContent == null) { throw new ArgumentException($"{nameof(textContent)} cannot be null"); } var encodedStringContentBytes = Encoding.UTF8.GetBytes(textContent); return((string)executeMethod.Execute(AppiumDriverCommand.SetClipboard, PrepareArguments(new[] { "content", "contentType", "label" }, new object[] { Convert.ToBase64String(encodedStringContentBytes), ClipboardContentType.PlainText.ToString().ToLower(), label })).Value); }
public static string GetClipboard(IExecuteMethod executeMethod, ClipboardContentType clipboardContentType) { switch (clipboardContentType) { case ClipboardContentType.Image: case ClipboardContentType.Url: if (executeMethod.GetType().GetGenericTypeDefinition() == typeof(AndroidDriver <>)) { throw new NotImplementedException($"Android only supports contentType: {nameof(ClipboardContentType.PlainText)}"); } return((string)executeMethod.Execute(AppiumDriverCommand.GetClipboard, PrepareArgument("contentType", clipboardContentType.ToString().ToLower())).Value); case ClipboardContentType.PlainText: return((string)executeMethod.Execute(AppiumDriverCommand.GetClipboard, PrepareArgument("contentType", clipboardContentType.ToString().ToLower())).Value); default: return((string)executeMethod.Execute(AppiumDriverCommand.GetClipboard, PrepareArgument("contentType", clipboardContentType.ToString().ToLower())).Value); } }
public static ConnectionType GetConection(IExecuteMethod executeMethod) { var commandResponse = executeMethod.Execute(AppiumDriverCommand.GetConnectionType, null); if (commandResponse.Status == WebDriverResult.Success) { return((ConnectionType)(long)commandResponse.Value); } else { throw new WebDriverException("The request to get the ConnectionType has failed."); } }
public static void LongPressKeyCode(IExecuteMethod executeMethod, int keyCode, int metastate = -1) { var parameters = new Dictionary <string, object>() { ["keycode"] = keyCode }; if (metastate > 0) { parameters.Add("metastate", metastate); } executeMethod.Execute(AppiumDriverCommand.LongPressKeyCode, parameters); }
public static void SetSetting(IExecuteMethod executeMethod, string setting, object value) { var settings = new Dictionary <string, object>() { [setting] = value }; var parameters = new Dictionary <string, object>() { ["settings"] = settings }; executeMethod.Execute(AppiumDriverCommand.UpdateSettings, parameters); }
public static void HideKeyboard(IExecuteMethod executeMethod, string strategy = null, string key = null) { Dictionary <string, object> parameters = new Dictionary <string, object>(); if (strategy != null) { parameters.Add("strategy", strategy); } if (key != null) { parameters.Add("keyName", key); } executeMethod.Execute(AppiumDriverCommand.HideKeyboard, parameters); }
public static void SetConection(IExecuteMethod executeMethod, ConnectionType connectionType) { Dictionary <string, object> values = new Dictionary <string, object>() { ["type"] = connectionType }; Dictionary <string, object> dictionary = new Dictionary <string, object>() { ["name"] = "network_connection", ["parameters"] = values }; executeMethod.Execute(AppiumDriverCommand.SetConnectionType, dictionary); }
public static void StartActivity(IExecuteMethod executeMethod, string appPackage, string appActivity, string appWaitPackage = "", string appWaitActivity = "", bool stopApp = true) { Contract.Requires(!string.IsNullOrWhiteSpace(appPackage)); Contract.Requires(!string.IsNullOrWhiteSpace(appActivity)); Dictionary <string, object> parameters = new Dictionary <string, object>() { ["appPackage"] = appPackage, ["appActivity"] = appActivity, ["appWaitPackage"] = appWaitPackage, ["appWaitActivity"] = appWaitActivity, ["dontStopAppOnReset"] = !stopApp }; executeMethod.Execute(AppiumDriverCommand.StartActivity, parameters); }
public static void StartActivityWithIntent(IExecuteMethod executeMethod, string appPackage, string appActivity, string intentAction, string appWaitPackage = "", string appWaitActivity = "", string intentCategory = "", string intentFlags = "", string intentOptionalArgs = "", bool stopApp = true) { Contract.Requires(!string.IsNullOrWhiteSpace(appPackage)); Contract.Requires(!string.IsNullOrWhiteSpace(appActivity)); Contract.Requires(!string.IsNullOrWhiteSpace(intentAction)); Dictionary <string, object> parameters = new Dictionary <string, object>() { ["appPackage"] = appPackage, ["appActivity"] = appActivity, ["appWaitPackage"] = appWaitPackage, ["appWaitActivity"] = appWaitActivity, ["dontStopAppOnReset"] = !stopApp, ["intentAction"] = intentAction, ["intentCategory"] = intentCategory, ["intentFlags"] = intentFlags, ["optionalIntentArguments"] = intentOptionalArgs }; executeMethod.Execute(AppiumDriverCommand.StartActivity, parameters); }
public static void ReplaceValue(IExecuteMethod executeMethod, string elementId, string value) => executeMethod.Execute(AppiumDriverCommand.ReplaceValue, new Dictionary <string, object>() { ["id"] = elementId, ["value"] = new string[] { value } });
public static Dictionary <string, object> GetSettings(IExecuteMethod executeMethod) => (Dictionary <string, object>)executeMethod.Execute(AppiumDriverCommand.GetSettings).Value;
public static bool IsLocked(IExecuteMethod executeMethod) => (bool)executeMethod.Execute(AppiumDriverCommand.IsLocked).Value;
public static void Unlock(IExecuteMethod executeMethod) => executeMethod.Execute(AppiumDriverCommand.UnlockDevice);
public static IDictionary <string, object> GetSystemBars(IExecuteMethod executeMethod) => executeMethod.Execute(AppiumDriverCommand.SystemBars).Value as IDictionary <string, object>;
public static float GetDisplayDensity(IExecuteMethod executeMethod) => Convert.ToSingle( executeMethod.Execute(AppiumDriverCommand.GetDisplayDensity).Value);
public static void ToggleAirplaneMode(IExecuteMethod executeMethod) => executeMethod.Execute(AppiumDriverCommand.ToggleAirplaneMode);
public static void OpenNotifications(IExecuteMethod executeMethod) => executeMethod.Execute(AppiumDriverCommand.OpenNotifications);
public static string GetCurrentActivity(IExecuteMethod executeMethod) => executeMethod.Execute(AppiumDriverCommand.GetCurrentActivity).Value as string;
public static void ToggleData(IExecuteMethod executeMethod) => executeMethod.Execute(AppiumDriverCommand.ToggleData);
public static void SetGsmVoice(IExecuteMethod executeMethod, GsmVoiceState gsmVoiceState) => executeMethod.Execute(AppiumDriverCommand.SetGsmVoiceState, PrepareArgument("state", gsmVoiceState.ToString() .ToLowerInvariant()));
public static void SetGsmStrength(IExecuteMethod executeMethod, GsmSignalStrength gsmSignalStrength) => executeMethod.Execute(AppiumDriverCommand.SetGsmSignalStrength, PrepareArgument("signalStrength", gsmSignalStrength));
public static void SendSms(IExecuteMethod executeMethod, string number, string message) => executeMethod.Execute(AppiumDriverCommand.SendSms, PrepareArguments(new[] { "phoneNumber", "message" }, new object[] { number, message }));
public static void GsmCall(IExecuteMethod executeMethod, string number, GsmCallActions gsmCallAction) => executeMethod.Execute(AppiumDriverCommand.GsmCall, PrepareArguments(new[] { "phoneNumber", "action" }, new object[] { number, gsmCallAction.ToString().ToLowerInvariant() }));
public static void ToggleWifi(IExecuteMethod executeMethod) => executeMethod.Execute(AppiumDriverCommand.ToggleWiFi);
public static string GetCurrentPackage(IExecuteMethod executeMethod) => executeMethod.Execute(AppiumDriverCommand.GetCurrentPackage).Value as string;
public static object[] GetPerformanceDataTypes(IExecuteMethod executeMethod) => executeMethod.Execute(AppiumDriverCommand.GetPerformanceDataTypes).Value as object[];
public static string EndTestCoverage(IExecuteMethod executeMethod, string intent, string path) => executeMethod.Execute(AppiumDriverCommand.EndTestCoverage, new Dictionary <string, object>() { ["intent"] = intent, ["path"] = path }).Value as string;
public static object[] GetPerformanceData(IExecuteMethod executeMethod, string packageName, string dataType, int dataReadTimeout) => executeMethod.Execute(AppiumDriverCommand.GetPerformanceData, PrepareArguments(new[] { "packageName", "dataType", "dataReadTimeout" }, new object[] { packageName, dataType, dataReadTimeout })).Value as object[];