javascript - 柏。删除表中的行并检查它
问题描述
我对Java几乎没有经验。所以我请你帮忙。情况是这样的
- 找出行数
- 删除行
- 检查行数是否比原来少一
这是我的代码。我很确定他错了。请帮助我如何在最后一步正确编写“行数 - 1”。谢谢 !
it('Step 5 - get the table row count', () => {
cy.getByTestId('user-management-roles-table-container')
.find("tr")
.then((row) => {
//row.length will give you the row count
cy.log(String(row.length))
});
});
it('Step 6 - Click on the 3 dots', () => {
cy.getByTestId('button-group-buttonGroup-dropdown-button').first().click();
cy.getByTestId('select-menu-buttonGroup-items-wrapper').should('be.visible');
});
it('Step 7 - Click on the "Delete" button', () => {
cy.getByTestId('select-menu-buttonGroup-value-delete').click();
});
it('Step 8 - ', () => {
cy.getByTestId('user-management-roles-table-container').find('tr').its('length').should('eq', "number of lines - 1" );
});
```
解决方案
你可以这样做:
let lenBefore;
it('Step 5 - get the before table row count', () => {
cy.getByTestId('user-management-roles-table-container').find("tr").its('length').then((len) => {
lenBefore = len;
cy.log('Initial table Length is: ' + lenBefore);
});
});
it('Step 6 - Click on the 3 dots', () => {
cy.getByTestId('button-group-buttonGroup-dropdown-button').first().click();
cy.getByTestId('select-menu-buttonGroup-items-wrapper').should('be.visible');
});
it('Step 7 - Click on the "Delete" button', () => {
cy.getByTestId('select-menu-buttonGroup-value-delete').click();
});
it('Step 5 - get the after table row count', () => {
cy.getByTestId('user-management-roles-table-container').find("tr").its('length').then((lenAfter) => {
cy.log('After table Length is: ' + lenAfter);
expect(lenBefore).to.equal(lenAfter - 1);
});
});
推荐阅读
- java - 使用 Keycloak 进行客户注册
- python - Python - 绘制方程:x + abs(x) = y + abs(y)
- python - Python 错误:ValueError:无法将字符串转换为浮点数
- c# - 如何将 C# 类型编组为 LPWSTR *
- twilio - 在 Twilio Whatsapp API 上对每条发送的消息进行“接受”回复
- reactjs - 在 TypeScript 中对 async/await 调用进行排序
- wpf - 即使 IsDesignTimeCreatable=False 也会创建 Viewmodel
- angular - 处理模型中与视图相关的属性的最佳方法(从远程服务获取)
- javascript - 如何在比较表中显示 json api 数据?
- heroku - 我们丢失了部署到 Heroku 的其中一个应用程序的源代码