赛普拉斯:为兄弟姐妹输入价值

Cypress: Enter value into siblings

我需要在“数量”字段下方的输入框中输入值。

我试过下面的代码,但没用

cy.contains('Quantity').siblings('input').type(123)

cy.contains('Quantity').siblings('div').type(123)

更好的方法是结合使用 parent()within

cy.contains('Quantity')
  .parent()
  .within(() => {
    cy.get('[inputmode="numeric"]').clear().type('123')
    cy.get('.cc-1mkztvr').clear().type('123') //In case above doesn't work, find element with class name
  })