Support simulation of Function keys
Are you requesting a feature or reporting a bug?
Feature
What is the current behavior?
You can't use .pressKey to simulate function keys (F1-F12).
What is the expected behavior?
You can use something like .pressKey('F2').
How would you reproduce the current behavior (if this is a bug)?
Provide the test code and the tested page URL (if applicable)
Tested page URL:
Test code
Specify your
- testcafe version: 0.18.0
- node.js version: 8.6.0
This would be useful! If not implemented soon, It'd be great to put a note in the docs to prevent future wild goose chases.
This would indeed be useful.
Indeed, this will be very useful so I hope it will be implemented soon, thanks.
This is something we really need. Is there any workaround? We are committed to TestCafe and absolutely need to test this feature
For anyone struggling with this, I got around it with the following: ` const pressF2 = ClientFunction(() => {
var event = new KeyboardEvent('keydown', { key: 'F2' });
document.dispatchEvent(event)
});
await pressF2();
`
Any update on this?
No updates yet. Once we get any results, we will post them in this thread.
Really needs this feature. Any plans for adding this?
We still plan to implement this feature. However, we work on features that are on our Roadmap first.
For anyone struggling with this, I got around it with the following: ` const pressF2 = ClientFunction(() => {
var event = new KeyboardEvent('keydown', { key: 'F2' }); document.dispatchEvent(event) }); await pressF2();`
For me it was a part of the solution (I work with TypeScript). I have solved the problem with:
` export const pressF1 = ClientFunction (() => {
const event= new KeyboardEvent('keydown', { code: 'F1' });
Object.defineProperty(event, 'keyCode', { get : () => 112 });
window.dispatchEvent(event);
} `
AND BEFORE that, I had to click to get focus an element (body)
Really guys, feature was reported almost 5 years ago!
We decided not to introduce built-in support for event simulation for Function keys. Please use one of the workarounds from this thread or use the t.dispatchEvent action.