Skip to content

Commit 12647aa

Browse files
authored
fix: use ToLowerInvariant in clipboard to follow invariant culture (#920)
* fix: use ToUpper in clipboard * Update AppiumCommandExecutionHelper.cs
1 parent bcfde8b commit 12647aa

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Appium.Net/Appium/AppiumCommandExecutionHelper.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public static bool IsKeyboardShown(IExecuteMethod executeMethod)
8585
public static void SetClipboard(IExecuteMethod executeMethod, ClipboardContentType clipboardContentType,
8686
string base64Content)
8787
{
88+
var contentType = clipboardContentType.ToString().ToLowerInvariant();
89+
8890
switch (clipboardContentType)
8991
{
9092
case ClipboardContentType.Image:
@@ -97,18 +99,19 @@ public static void SetClipboard(IExecuteMethod executeMethod, ClipboardContentTy
9799

98100
executeMethod.Execute(AppiumDriverCommand.SetClipboard,
99101
PrepareArguments(new[] {"content", "contentType", "label"},
100-
new object[] {base64Content, clipboardContentType.ToString().ToLower(), null}));
102+
new object[] {base64Content, contentType, null}));
101103
break;
102104
default:
103105
executeMethod.Execute(AppiumDriverCommand.SetClipboard,
104106
PrepareArguments(new[] {"content", "contentType", "label"},
105-
new object[] {base64Content, clipboardContentType.ToString().ToLower(), null}));
107+
new object[] {base64Content, contentType, null}));
106108
break;
107109
}
108110
}
109111

110112
public static string GetClipboard(IExecuteMethod executeMethod, ClipboardContentType clipboardContentType)
111113
{
114+
var contentType = clipboardContentType.ToString().ToLowerInvariant();
112115
switch (clipboardContentType)
113116
{
114117
case ClipboardContentType.Image:
@@ -118,15 +121,12 @@ public static string GetClipboard(IExecuteMethod executeMethod, ClipboardContent
118121
throw new NotImplementedException(
119122
$"Android only supports contentType: {nameof(ClipboardContentType.PlainText)}");
120123
}
121-
122-
return (string) executeMethod.Execute(AppiumDriverCommand.GetClipboard,
123-
PrepareArgument("contentType", clipboardContentType.ToString().ToLower())).Value;
124-
case ClipboardContentType.PlainText:
125124
return (string) executeMethod.Execute(AppiumDriverCommand.GetClipboard,
126-
PrepareArgument("contentType", clipboardContentType.ToString().ToLower())).Value;
125+
PrepareArgument("contentType", contentType)).Value;
127126
default:
127+
// including ClipboardContentType.PlainText
128128
return (string) executeMethod.Execute(AppiumDriverCommand.GetClipboard,
129-
PrepareArgument("contentType", clipboardContentType.ToString().ToLower())).Value;
129+
PrepareArgument("contentType", contentType)).Value;
130130
}
131131
}
132132

@@ -144,7 +144,7 @@ public static string SetClipboardText(IExecuteMethod executeMethod, string textC
144144
new object[]
145145
{
146146
Convert.ToBase64String(encodedStringContentBytes),
147-
ClipboardContentType.PlainText.ToString().ToLower(), label
147+
ClipboardContentType.PlainText.ToString().ToLowerInvariant(), label
148148
})).Value;
149149
}
150150

@@ -214,4 +214,4 @@ internal static Dictionary<string, object> PrepareArguments(string[] names, obje
214214
return parameterBuilder;
215215
}
216216
}
217-
}
217+
}

0 commit comments

Comments
 (0)