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

javascript - Cypress: How to mock key board (CTRLSHIFT) actions - Stack Overflow

programmeradmin0浏览0评论

As shown in picture i have these elements in a tree.If i press CTRL in KEY BOARD and click on these text-i can select multiple elements and it will give links to do some actions.Using cypress is there any way to achieve this ? i know if it is select, i can use select -in my case these are just 'ul'.Also i know while tying text we have options, is there any options in cypress to mock this Key board action while click or selecting elements

As shown in picture i have these elements in a tree.If i press CTRL in KEY BOARD and click on these text-i can select multiple elements and it will give links to do some actions.Using cypress is there any way to achieve this ? i know if it is select, i can use select -in my case these are just 'ul'.Also i know while tying text we have options, is there any options in cypress to mock this Key board action while click or selecting elements

Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Mar 6, 2019 at 2:34 user8710571user8710571 4552 gold badges14 silver badges25 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

We are using this syntax:

cy.get('body')
  .type('{alt}', {release: false})
cy.get('.heading')
  .click()
cy.get('.tooltip__header')
  .should('contain', 'Translate')

So in your case it would be something like this:

cy.get('body')
  .type('{ctrl}', {release: false})
cy.get('Sugar CSP Segmentation')
  .click()
cy.get('Health & Welness Segments')
  .click()

An alternative syntax, which reads more intuitively IMO, is to pass the ctrlKey option (documentation):

cy.get('Sugar CSP Segmentation').click()
cy.get('Health & Welness Segments').click({ctrlKey: true})
发布评论

评论列表(0)

  1. 暂无评论