无法验证文本字段中的文本-柏树



我得到了以下文本字段:

<div _ngcontent-c11="" class="input-container" data-testid="my-textfield"><div _ngcontent-c11="" class="title-container-input"><input _ngcontent-c11="" type="text" ng-reflect-model="my content" class="ng-pristine ng-valid ng-touched"></div><!--bindings={
"ng-reflect-ng-if": "false"
}--></div>

我试图检查文本字段是否具有内容";我的内容";我试过以下几种:

cy.getBySel('my-textfield').should('have.text', 'my content')

也尝试过:

cy.getBySel('my-textfield').should('contain', 'my content')

我也尝试过include,但不起作用。

我得到以下错误:

expected <div.input-container> to have text my content, but the text was ''

有人知道为什么这不起作用吗。

如果我做了一个类型,它是工作的,但验证文本字段的内容不工作。

谢谢

你可以这样做:

cy.getBySel('my-textfield').find('input').should('have.text', 'my content')
//OR
cy.getBySel('my-textfield').find('input').should('have.value', 'my content')

最新更新