Cypress - 从 mat-button-toggle-group 获取 [value] value 属性

Hug*_*iro 2 angular-material angular cypress

我有一个选择器<mat-button-toggle-group [value]="myValue"></mat-button-toggle-group>

我想要获得[value]价值,为此我做到了。

buttonToggleGroupSelector.should('exist').and('has.value', 'MyValue');
Run Code Online (Sandbox Code Playgroud)

但这返回一个空字符串而不是属性值。

Let*_*ave 6

当你使用

buttonToggleGroupSelector.should('exist').and('has.value', 'MyValue');
Run Code Online (Sandbox Code Playgroud)

Cypress 正在寻找value属性,但您想要该value属性

buttonToggleGroupSelector.should('exist').and('has.attr', 'value', 'MyValue');
Run Code Online (Sandbox Code Playgroud)