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;
            }
        }
Exemplo n.º 2
0
        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);
            }
        }