【问题标题】:cannot trigger click on prime ng time calendar无法触发点击黄金时段日历
【发布时间】:2021-05-17 23:16:58
【问题描述】:

我有一个带有prime ng日历的角度应用程序。 以下是我的示例代码:

<p-calendar [(ngModel)]="myDate" [inline]="true" [timeOnly]="true"></p-calendar>

这是从最初的 ng 开始的修改后的 stackblitz:

stackblitz

出于测试目的,我想通过强制点击人字形上/下图标以编程方式更改时间,例如使用 cypress 命令:

cy.get('.pi-chevron-up').first().click();

不幸的是,我无法使用 jquery 函数实现触发器(请参阅附加的 stackblitz)。

有人可以帮忙吗?

【问题讨论】:

    标签: jquery calendar cypress primeng


    【解决方案1】:

    对我来说没问题,这是我的测试

    it('increments the counter via chevron click', () => {
    
      cy.visit('http://localhost:4200')
    
      let initial, next;
    
      cy.get('.pi-chevron-up')
        .first()
        .parent()
        .next('span')
        .then($el => initial = +$el.text())
    
      cy.wrap([1,2,3]).each(() => {   // do it 3 times
    
        cy.get('.pi-chevron-up')
          .first()
          .click()
    
        cy.get('.pi-chevron-up')
          .first()
          .parent()
          .next('span')
          .then($el => next = +$el.text())
          .then(() => {
            expect(next).to.eq(initial + 1)
            initial = next
          })
      })
    
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-01
      • 2021-03-02
      相关资源
      最近更新 更多