Network interception in selenium with node js

72 views
Skip to first unread message

Dhanush Srinivas

unread,
Nov 17, 2022, 7:29:11 AM11/17/22
to Selenium Users
Hey, I need to send a post request to an API and get a response body to validate it.
There is almost no material online related to this. Can someone please help me out with this problem?

This is the cypress code snippet

 cy.intercept('POST', '/myapi/admin/getIntegrations').as('searchResult')
cy.wait('@searchResult', { requestTimeout: 30000 }).then(i => { cy.get('td.mat-column-request > button').eq(0).click() cy.get('.mat-dialog-content > * p').invoke('text').then(req => { req = JSON.parse(req) expect(req).to.have.property('event', "course.created") expect(req.data[0].course).to.have.property('employeeId', employeeId) expect(req.data[0].course).to.have.property('courseName', courseName) expect(req.data[0].course).to.have.property('createdBy', 'abcd') expect(req.data[0].course).to.have.property('status', 'In Progress') expect(req.data[0].course).to.have.property('enabled', 1) })
Reply all
Reply to author
Forward
0 new messages