我尝试使用WinAppDriver进行UI测试。Sendkeys()发送QWERTY txt,而我使用AZERTY布局。
我设法用这种方式重排字符,但它对数字不起作用:
public static async Task<WindowsElement> SendKeyAndWait(this WindowsElement element, string azertyText, int secondsToWaitAfter = 0, int secondsToWaitFirst = 1)
{
await element.ClickAndWait(secondsToWaitFirst);
element.SendKeys(azertyText
.Replace("a", "q")
.Replace("m", ";")
.Replace("z", "w")
.Replace(",", "m") //WinAppDriver ne connait que le clavier qwerty donc q => a
.Replace("1", "&") //semble ne pas fonctionner pour les chiffres
.Replace("0", "à")
);
await Task.Delay(secondsToWaitAfter);
return element;
}
Has anyone already solved this issue ?
Thanks for your answers发布于 2021-06-15 23:10:24
这个问题已经提出来了,并且仍然是悬而未决的(4年!)在WinAppDriver repo.上
这是一位用户建议的解决方法。
private static void SwitchToUsKeyboard()
{
var switchKeyboardLayoutActions = new Actions(AppSession);
switchKeyboardLayoutActions.SendKeys(Keys.Control + "0" + Keys.Control);
switchKeyboardLayoutActions.Build();
switchKeyboardLayoutActions.Perform();
}
private static void SwitchToFrKeyboard()
{
var switchKeyboardLayoutActions = new Actions(AppSession);
switchKeyboardLayoutActions.SendKeys(Keys.Control + "1" + Keys.Control);
switchKeyboardLayoutActions.Build();
switchKeyboardLayoutActions.Perform();
}您必须首先使用美国键盘设置美国语言(以及本例中的法语)。然后,您需要为这些键盘添加快捷键。

https://stackoverflow.com/questions/67381189
复制相似问题