https://cypress.io logo
Delete Row By Id in table
# i-need-help
b
How delete row by id in this angular table? i don't have any field that list the row id.
Copy code
ts
let id;
it('create_category', () => {
    cy.login();
    cy.visit('/backoffice/communication/category/create');
    
    cy.get('.ng-tns-c22-15 > .ant-form-item-control > .ant-form-item-children > .ant-input').clear();
    cy.get('.ng-tns-c22-15 > .ant-form-item-control > .ant-form-item-children > .ant-input').type('teste');
    cy.get('.ng-tns-c22-4 > .ant-form-item-control > .ant-form-item-children > .ant-input').clear();
    cy.get('.ng-tns-c22-4 > .ant-form-item-control > .ant-form-item-children > .ant-input').type('12');
    cy.get('.ant-switch').click();
    
    cy.intercept('POST', '/api/communication/categories').as('createCategory');
    cy.get('.button-submit').click();
    cy.wait('@createCategory').then((interception) => {
        id = interception.response.body.data[0].id
        console.log(id)
        expect(interception.response.statusCode).to.eq(200)
    });

})


it('delete_category', () => {
    cy.login();
    cy.visit('/backoffice/communication/category/list');
    cy.intercept('DELETE', '/backoffice/communication/categories/' + id).as('deleteCategory');

    cy.get(':nth-child(1) > .text-right > .options_button').click();
    cy.get('.ant-dropdown-menu > :nth-child(2)').click();
    cy.get('.ant-btn-danger').click();

    cy.wait('@deleteCategory').then((interception) => {
        expect(interception.response.statusCode).to.eq(200)
      });
})
I try this...
g
why don't you delete it by text that does appear in the row you just created?
b
because i want to test the endpoint
Give me a example please
I didn't understand your feedback well
g
you are adding new row to the table, right. The new row with text "my new test 123" appears. Then you find the same text and go back up to the row and delete it
b
thank you
its works
5 Views