我正在开发一个使用赛普拉斯实现自动化的项目。在这个项目中,我需要为患者创建一个订单。当我单击提交按钮时,它将https://ibis-dev.droicelabs.us/api/dispenser/orders/
使用 POST 方法调用以下 API 并返回我想要获取的唯一订单。
我已经cy.intercept
像这样在我的测试之上注册:
cy.intercept({
method: 'POST',
url: 'https://ibis-dev.droicelabs.us/api/dispenser/orders/',
}).as('ordersCall')
当单击提交按钮时,我使用了:
cy.clickOnElementUsingXpath(practicePageSelectors.submit_CreateOrderButton); // click on submit button
cy.wait('@ordersCall')
.its('response.body')
.then((body) => {
// parsing might be not needed always, depends on the api response
const bodyData = JSON.parse(body)
cy.log(bodyData)
})
但它返回以下错误:
Timed out retrying after 5000ms: cy.wait() timed out waiting 5000ms for the 1st request to the route: ordersCall. No request ever occurred in cy.wait('@ordersCall')
谁能帮我获取orderID?有没有其他方法可以获取 orderID?