最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Cypress: type combination of keys and keyCodes - Stack Overflow

programmeradmin2浏览0评论

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 badges
Add a ment  | 

2 Answers 2

Reset to default 5

Try .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.

发布评论

评论列表(0)

  1. 暂无评论