使用赛普拉斯下拉选择值不会发生

时间:2019-08-15 07:36:04

标签: cypress

如何使用赛普拉斯选择dropdown值,它建立在角度页面上。默认情况下,选择字段显示如下。第一个选项是单击下拉列表,但不单击值,我已经尝试过eq(1),eq(2)..但是还不能正常工作。

enter image description here

我在cypress中尝试了以下选项,但这些选项不起作用;

选项:1

cy.get('.mat-select-value > span').eq(0).then((option)=>{
  cy.wrap(option).eq(0).click();
})

选项2:

cy.get('.mat-select-value > span').contains("Phase 4 - Boond ").click();

//附加了html:

enter image description here

1 个答案:

答案 0 :(得分:1)

您可能想尝试一下:

cy.get('.mat-select-value > span').eq(0).click() // to open the drop down
cy.get('.mat-option').contains('Phase 4 - Boond').click() // to click the actual option