赛普拉斯URL匹配查询

时间:2019-10-06 23:21:13

标签: routes cypress

在Cypress.io中,我尝试使用cy.route来匹配请求,以确保在继续操作之前已加载整个页面。

   cy.server();
   cy.route({
       'https://dev.flurosat.com/histogram**',
       method: 'GET'
   }).as(getHistogram)
  cy.wait('@getHistogram')

在“网络”标签中,我正在清除响应,但显示响应后我的cy.wait超时。
enter image description here

看来我的定位模式不匹配。

在此测试中,我有非常相似的cy.route命令,并且所有命令都可以正确接收,但是这些其他命令将匹配具有https://dev.flurosat.com/weather/**http://dev.flurosat.com/groups/**形式的路由,其中​​{{ 1}}后跟**,而不是查询字符串。

是否可以匹配此路线?

我不想与/匹配,因为这太笼统了。

谢谢

2 个答案:

答案 0 :(得分:0)

似乎您切换了方法和URL。这种语法确实对我有用:

private void compareTime(String lastTime) {

            SimpleDateFormat format = new SimpleDateFormat("hh:mm:ss aa", Locale.US);
            String currentTime = format.format(new Date(System.currentTimeMillis()));

            Date date2 = null;
            Date date1 = null;
            try {
                date1 = format.parse(lastTime);
                date2 = format.parse(currentTime);
            } catch (ParseException e) {
                e.printStackTrace();
            }
            assert date2 != null;
            long difference = (date2.getTime() - date1.getTime()) / 1000;
            long hours = difference % (24 * 3600) / 3600; // Calculating Hours
            long minute = difference % 3600 / 60; // Calculating minutes if there is any minutes difference
            long min = minute + (hours * 60);
            if (min > 24 || min < -24) {

            }

}

您甚至不必完全写出URL,这也可以正常工作:cy.server(); cy.route('GET', 'https://dev.flurosat.com/histogram**').as(getHistogram)

答案 1 :(得分:0)

看来您做对了,但是使用相对网址也对我有用

  cy.server();         
  cy.route({ method: 'GET', url: '/histogram**' }).as('getHistogram');