Open hicks86 opened 5 years ago
SendKeys() is like this, it's a POST function, so whenever you as the developer calls that method, all you are doing is telling the local WinAppDriver to send some type of keyboard command to a specific element.
What you actually want to check out, is generically telling the the server to not send anything to any element, but press the F6 key like so as long as you are focused in on your application:
session.Keyboard.PressKey(OpenQA.Selenium.Keys.F6);
Hi @Rangyia thanks for the response. Yup that what I assumed as much.
So I dug a little deeper into what was actually being sent. So according to this Windows help documentation on the WindowsForm.Keys enum (https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.keys) the value that should be sent from pressing the F6 key is 117.
I put together a quick WinForm app to capture OnKeyDown event. Using the keyboard manual approach I received 117
.
However driving the app from Appium using the code you suggested I receive 255 117 255
.
With some further investigation it looks like the app that I am testing will disable the mode if it receives any other keys. So hence the reason why I am seeing the particular mode come on, then immediately switch off.
So the Selenium.Keys.F6 (and I imagine many more) is not sending the exact same KeyValue as the Window Forms Keys spec. Not sure if this is a problem for anyone else but it caused me issues.
As a work around I am now using SendKeys.SendWait("{F6}");
from the System.Windows.Forms namespace (https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys). This works a treat and is significantly quicker.
Using Appium and WinAppdriver to test drive our Microsoft Word Addin (using Addin-Express). So far I have been able to do most things however hitting a bit of a brick wall with the .SendKeys() functionality.
I want to send a Function key to toggle a particular mode on the addin (keyboard driven mode) This is what I am currently doing:
The result is that it switches the F6 mode on for a split-second then switches it off - (I can tell as a little keyboard will appear when this mode is active, and disappears when it is not).
Any ideas why it this is occurring?
Below is the AppiumLog