示例#1
0
        public static void SetClipboardUrl(IExecuteMethod executeMethod, string url)
        {
            var urlEncoded     = WebUtility.UrlEncode(url);
            var base64UrlBytes = Encoding.UTF8.GetBytes(urlEncoded);

            AppiumCommandExecutionHelper.SetClipboard(executeMethod, ClipboardContentType.Url, Convert.ToBase64String(base64UrlBytes));
        }
示例#2
0
        public static string GetClipboardUrl(IExecuteMethod executeMethod)
        {
            var content         = AppiumCommandExecutionHelper.GetClipboard(executeMethod, ClipboardContentType.Url);
            var urlEncodedBytes = Convert.FromBase64String(content);
            var urlDecodedBytes = Encoding.UTF8.GetString(urlEncodedBytes);

            return(WebUtility.UrlDecode(urlDecodedBytes));
        }
示例#3
0
        public static Image GetClipboardImage(IExecuteMethod executeMethod)
        {
            var imageBytes = Convert.FromBase64String(
                AppiumCommandExecutionHelper.GetClipboard(executeMethod, ClipboardContentType.Image));

            if (imageBytes.Length > 0)
            {
                return(Image.FromStream(new MemoryStream(imageBytes)));
            }

            return(null);
        }
示例#4
0
        public static void SetClipboardImage(IExecuteMethod executeMethod, Image image)
        {
            byte[] imageBytes;
            using (var memoryStream = new MemoryStream())
            {
                image.Save(memoryStream, ImageFormat.Png);
                imageBytes = memoryStream.ToArray();
            }

            AppiumCommandExecutionHelper.SetClipboard(executeMethod,
                                                      ClipboardContentType.Image,
                                                      Convert.ToBase64String(imageBytes));
        }
示例#5
0
 /// <summary>
 /// Locks the device.
 /// </summary>
 /// <param name="seconds">The number of seconds during which the device need to be locked for.</param>
 public void Lock(int seconds) => AppiumCommandExecutionHelper.Lock(this, seconds);
示例#6
0
 public void HideKeyboard(string key, string strategy = null) =>
 AppiumCommandExecutionHelper.HideKeyboard(this, strategy, key);
 /**
  * This method locks a device.
  */
 public void Lock() => AppiumCommandExecutionHelper.Lock(this, 0);
 public void LongPressKeyCode(int keyCode, int metastate = -1) => AppiumCommandExecutionHelper.LongPressKeyCode(this, keyCode, metastate);
 /// <summary>
 /// Get the plaintext content of the clipboard.
 /// </summary>
 /// <remarks>Android supports plaintext only</remarks>
 /// <returns>The string content of the clipboard or an empty string if the clipboard is empty</returns>
 public string GetClipboardText() => AppiumCommandExecutionHelper.GetClipboardText(this);
 /// <summary>
 /// Sets text to the clipboard
 /// </summary>
 /// <param name="textContent"></param>
 /// <param name="label">For Android only - A user visible label for the clipboard content.</param>
 public void SetClipboardText(string textContent, string label) => AppiumCommandExecutionHelper.SetClipboardText(this, textContent, label);
 /// <summary>
 /// Get the content of the clipboard.
 /// </summary>
 /// <param name="contentType"></param>
 /// <remarks>Android supports plaintext only</remarks>
 /// <returns>The content of the clipboard as base64-encoded string or an empty string if the clipboard is empty</returns>
 public string GetClipboard(ClipboardContentType contentType) => AppiumCommandExecutionHelper.GetClipboard(this, contentType);
 /// <summary>
 /// Sets the content to the clipboard
 /// </summary>
 /// <param name="contentType"></param>
 /// <param name="base64Content"></param>
 public void SetClipboard(ClipboardContentType contentType, string base64Content) => AppiumCommandExecutionHelper.SetClipboard(this, contentType, base64Content);
示例#13
0
 public static void SetClipboardImage(IExecuteMethod executeMethod, string base64EncodeImage)
 {
     AppiumCommandExecutionHelper.SetClipboard(executeMethod, ClipboardContentType.Image, base64EncodeImage);
 }