I need to navigate through the keyboard pressing ALT+F10.
I know that is possible to type mands like this:
cy.focused().type('{alt}')
How can I add the F10 key to this mand?
Thanks
I need to navigate through the keyboard pressing ALT+F10.
I know that is possible to type mands like this:
cy.focused().type('{alt}')
How can I add the F10 key to this mand?
Thanks
Share Improve this question asked May 23, 2019 at 14:05 VictorVictor 7623 gold badges15 silver badges33 bronze badges2 Answers
Reset to default 5Try .trigger
with altKey:true
(for pressing down alt
) and keyCode: 121
for the F10 key:
cy.get('body').trigger('keydown', { altKey: true, keyCode: 121, which: 121 })
I think you want to read the documentation on Key Combinations
I can't test it right now but I suppose following code could work:
cy.get('input').type('{alt}', { release: false }) // this should keep alt pressed
cy.get('input').trigger('keydown', { keyCode: 121, which: 121 }) // trigger F10 keycode
Anyway, read the documentation about { release: false })
option of .type
, you should find your answer there.
Note: You cannot type F10 using {f10} because it's not built in Cypress yet. The special characters which are built in are described HERE.