cypress - 如何在表格网格中查找按钮元素

标签 cypress getelementsbytagname findelement

我是 Cypress 的新手。 我有一个用户表,每一行都有编辑按钮。我想通过电子邮件找到特定用户,然后单击该行中的编辑按钮。您能帮我找到 Cypress 测试的编辑按钮吗?

enter image description here

最佳答案

比这更容易。

您可以使用 <tr> 找到正确的行( <td> 不是 .contains() ) .

然后找到 <a>在该行内

cy.contains('tr', 'Joei Smithi')  // whichever bit of text id's them, 
                                  // but specify 'tr' as the element
                                  // Checks all the row children, but returns the row
  .find('a')                      // Now find() looks only in that row, and any depth
  .click()                        // hit it 

关于cypress - 如何在表格网格中查找按钮元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69444828/

相关文章:

javascript - Cypress:键入键和键代码的组合

java - 使用 JAVA 将标签从 xml 文件导入到另一个文件

php - DOM结构,通过属性名/值获取元素

python - Selenium 无法通过 Xpath 查找元素?

java - 我怎样才能用Java找到id、css元素的文本

cypress - 自定义事件和 cy.get

typescript - Cypress 10 : Custom command is not a function

javascript - 与 getElementsByTagName 相关的问题

python - 使用 selenium Python 查找正确的 xpath

javascript - 检查 Cypress 中的单选按钮