WinAppDriver/AZERTY 键盘:sendkeys() 没有正确发送数字
WinAppDriver / AZERTY Keyboard : sendkeys() doesn't send correctly the numbers
我尝试使用 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
此问题已在 WinAppDriver repo.
上提出并仍未解决(4 年!)
这是用户在那里建议的解决方法。
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();
}
您必须首先使用美式键盘设置美式语言(以及本例中的法语)。然后你需要为这些键盘添加快捷方式。
我尝试使用 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
此问题已在 WinAppDriver repo.
上提出并仍未解决(4 年!)这是用户在那里建议的解决方法。
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();
}
您必须首先使用美式键盘设置美式语言(以及本例中的法语)。然后你需要为这些键盘添加快捷方式。