我需要为某些网络调用添加cy.wait(),该网络呼叫中有参数,其中包含前向斜线。

问题描述 投票:0回答:1

cy.intercept('http://example.com/myPage1**').as('myPage1');

,但是,cy.wait('@myPage1').its('response.statusCode').should('eq',200);正在计时,测试案例失败。

可以用url的正则表达式捕获它。
您不需要指定基本部分
http://example.com

。 chars

/

?
cypress cypress-intercept
1个回答
11
投票
\

表示字面特征。

cy.intercept(/\/myPage1\?/).as('myPage1')

近来,

cy.intercept({pathname: '**/myPage1'}, {}).as('myPage1')

用baseurl测试:
const { defineConfig } = require("cypress");

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
    baseUrl: 'http://192.168.43.82/font-end/#/'
  },
});
应用程序获取

fetch('http://192.168.43.82/rest/api/myPage1?id=598dccc6&startDate=10/01/2023&endDate=11/01/2023')
    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.