Muh*_*lal 2 javascript cypress
想要自动化:

我的代码:

cy.get('[role=presentation]') cy.get('[role=row]').find('td')
.get('[role=gridcell]').eq(9).click().wait(2000)
cy.get('[role=listbox]').get('[role=option]')
cy.contains('[role=option]', 'Numeric').click()
Run Code Online (Sandbox Code Playgroud)
如果列表包含带有该文本的其他值,如何从列表中仅选择“数字”。
您询问如何与选项“Numeric”进行精确匹配,以便从搜索中排除选项“AlphaNumeric”。
为此,请将cy.contains()命令更改为使用正则表达式。这允许将start-of-string和end-of-string标记包含在表达式中,从而为您提供 和 完全匹配。
^是字符串开头,$也是字符串结尾。
// cy.contains('[role=option', 'Numeric') //matches two options
cy.contains('[role=option', /^Numeric$/) //matches one option only
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
75 次 |
| 最近记录: |