angular-material - 如何使用剧作家获得垫选元素的价值?
问题描述
我是 Playwright 的新手,我试图获取选定的选项值并将其更改为使用 playwright 的 mat-form-field 包含 mat-select 元素的另一个选项。
我试过了
await page.selectOption('select#colors', { label: 'Blue' });
即 selectOptions 不适用于垫选择元素
<mat-form-field>
<mat-select id="selectColor" [formControl]="colcorselect" (click)="$event.stopPropagation()">
<mat-option *ngFor="let filter of savedColorOptions" [value]="filter (click)="savedFilterChange($event, filter)">
{{filter}}
</mat-option> </mat-select> </mat-form-field>
解决方案
这是最终对我有用的两个步骤:
首先单击它作为普通 UI 对象。
然后单击所需的选项值。
let cmb_box_locator='mat-select[id="myCombo"]' await page.click(cmb_box_locator) await page.click('//span[@class="mat-option-text"][contains(.,"'+desiredValue+'")]')
推荐阅读
- video - 新 Instagram API 的 ffmpeg 视频长宽比
- unix - 连接来自 shell 脚本中不同文件的两个不同字符串
- php - 带有 curl 字符串的 shell_exec
- arrays - UByteArray 相等运算符
- python - 循环遍历文本文件中的元组列表
- git - 永久删除 git 提交历史
- reactjs - 声明的 const 变量在 useEffect 中不可见
- c# - 如何在 C# 中向 google doc 表格单元格添加内容
- angular - 当表单未创建时如何让我的页面听“输入”键
- swiftui - 使用 SwiftUI 的 relativeWidth 仅适用于框架视图