Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use ToLowerInvariant in clipboard to follow invariant culture #920

Merged
merged 2 commits into from
Mar 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Appium.Net/Appium/AppiumCommandExecutionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public static bool IsKeyboardShown(IExecuteMethod executeMethod)
public static void SetClipboard(IExecuteMethod executeMethod, ClipboardContentType clipboardContentType,
string base64Content)
{
var contentType = clipboardContentType.ToString().ToLowerInvariant();

switch (clipboardContentType)
{
case ClipboardContentType.Image:
Expand All @@ -97,18 +99,19 @@ public static void SetClipboard(IExecuteMethod executeMethod, ClipboardContentTy

executeMethod.Execute(AppiumDriverCommand.SetClipboard,
PrepareArguments(new[] {"content", "contentType", "label"},
new object[] {base64Content, clipboardContentType.ToString().ToLower(), null}));
new object[] {base64Content, contentType, null}));
break;
default:
executeMethod.Execute(AppiumDriverCommand.SetClipboard,
PrepareArguments(new[] {"content", "contentType", "label"},
new object[] {base64Content, clipboardContentType.ToString().ToLower(), null}));
new object[] {base64Content, contentType, null}));
break;
}
}

public static string GetClipboard(IExecuteMethod executeMethod, ClipboardContentType clipboardContentType)
{
var contentType = clipboardContentType.ToString().ToLowerInvariant();
switch (clipboardContentType)
{
case ClipboardContentType.Image:
Expand All @@ -118,15 +121,12 @@ public static string GetClipboard(IExecuteMethod executeMethod, ClipboardContent
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;
PrepareArgument("contentType", contentType)).Value;
default:
// including ClipboardContentType.PlainText
return (string) executeMethod.Execute(AppiumDriverCommand.GetClipboard,
PrepareArgument("contentType", clipboardContentType.ToString().ToLower())).Value;
PrepareArgument("contentType", contentType)).Value;
}
}

Expand All @@ -144,7 +144,7 @@ public static string SetClipboardText(IExecuteMethod executeMethod, string textC
new object[]
{
Convert.ToBase64String(encodedStringContentBytes),
ClipboardContentType.PlainText.ToString().ToLower(), label
ClipboardContentType.PlainText.ToString().ToLowerInvariant(), label
})).Value;
}

Expand Down Expand Up @@ -214,4 +214,4 @@ internal static Dictionary<string, object> PrepareArguments(string[] names, obje
return parameterBuilder;
}
}
}
}