赛普拉斯测试单选按钮值
Cypress to test Radio Button Value
我正在为无线电编写 cypress 测试以检查它是私有的还是 public。
HTML 节
<div _ngcontent-c6="" class="form-check form-check-inline mb-1">`
<input _ngcontent-c6="" class="form-check-input ng-untouched ng-pristine ng-valid" formcontrolname="projectStatus" id="private" name="projectStatus" type="radio" ng-reflect-name="projectStatus" ng-reflect-form-control-name="projectStatus" ng-reflect-value="false" ng-reflect-model="false">
<label _ngcontent-c6="" class="form-check-label" for="private">Private</label>
</div>
赛普拉斯测试
cy.get('#private').should('have.attr', 'checked', 'true') // Not working
cy.get('[type="radio"]').should('have.attr', 'ng-reflect-value', 'false') // Not Working
部分问题是当我在控制台时看到消息 <input#private.form-check-input.ng-untouched.ng-pristine.ng-valid>
我找不到属性 ng-reflect-checked
有人对 Angular 中制作的单选按钮进行过 cypress 测试吗?
好吧,我在输入中添加了一个值属性
<input _ngcontent-c6="" class="form-check-input ng-untouched ng-pristine ng-valid" formcontrolname="projectStatus" id="private" name="projectStatus" type="radio" ng-reflect-name="projectStatus" ng-reflect-form-control-name="projectStatus" ng-reflect-value="false" ng-reflect-model="false" **value="false"**>
赛普拉斯代码
cy.get('#private').should('have.attr', 'value', 'false')
我希望有人有更好的解决方案。
这也是一个解决方案:
cy.get('for=["private"]')
.parent()
.find('input')
.should('be.checked')
这样您就不需要输入元素的额外属性。
我正在为无线电编写 cypress 测试以检查它是私有的还是 public。
HTML 节
<div _ngcontent-c6="" class="form-check form-check-inline mb-1">`
<input _ngcontent-c6="" class="form-check-input ng-untouched ng-pristine ng-valid" formcontrolname="projectStatus" id="private" name="projectStatus" type="radio" ng-reflect-name="projectStatus" ng-reflect-form-control-name="projectStatus" ng-reflect-value="false" ng-reflect-model="false">
<label _ngcontent-c6="" class="form-check-label" for="private">Private</label>
</div>
赛普拉斯测试
cy.get('#private').should('have.attr', 'checked', 'true') // Not working
cy.get('[type="radio"]').should('have.attr', 'ng-reflect-value', 'false') // Not Working
部分问题是当我在控制台时看到消息 <input#private.form-check-input.ng-untouched.ng-pristine.ng-valid>
我找不到属性 ng-reflect-checked
有人对 Angular 中制作的单选按钮进行过 cypress 测试吗?
好吧,我在输入中添加了一个值属性
<input _ngcontent-c6="" class="form-check-input ng-untouched ng-pristine ng-valid" formcontrolname="projectStatus" id="private" name="projectStatus" type="radio" ng-reflect-name="projectStatus" ng-reflect-form-control-name="projectStatus" ng-reflect-value="false" ng-reflect-model="false" **value="false"**>
赛普拉斯代码
cy.get('#private').should('have.attr', 'value', 'false')
我希望有人有更好的解决方案。
这也是一个解决方案:
cy.get('for=["private"]')
.parent()
.find('input')
.should('be.checked')
这样您就不需要输入元素的额外属性。