这应该可行,请参阅文档:https://github.com/karatelabs/karate/tree/master/karate-core#attribute
我建议尽量不要使用XPath,CSS更好。
* def ariaChecked = attribute('#mat-slide-toggle-1-input', 'aria-checked')
请参阅其他答案以获取更多想法:https://stackoverflow.com/search?q=%5Bkarate%5D+attribute+ui