在赛普拉斯中,我cy.route()
用于发送以下请求,但赛普拉斯没有识别以下请求发送。在路由 url 中有一个 openHash 值,每个 POST 请求都会有所不同。有什么方法可以忽略 openHash 值或接受那里显示的任何值。
到目前为止,我已经尝试通过以下方式在路由中提供 url。
url: '**/student/details.php?viewDetails=project&stdCount=1§ionID=1&openHash=**',
url: '**/student/details.php?viewDetails=project&stdCount=1§ionID=1&openHash=**&ajaxCall=true**',
我相信在使用 cy.route() 时,POST url 需要完全匹配。有人可以建议吗
Cypress version: 5.4.0
Student.feature
Feature: Update student details
Background: User logged in to application
Given I should load all of the routes required for tests
Scenario: Update student details
When I am logged in as the student user
And I click on "Student" subtab
And I should see details displayed
Step definition
:
import { Then, When, And } from "cypress-cucumber-preprocessor/steps";
before(() => {
Then('I should load all of the routes required for tests', () => {
cy.server();
cy.route({
method: 'POST',
url: '**student/details.php?viewDetails=project&stdCount=1§ionID=1&openHash=5fc8329a76e73&ajaxCall=true**',
delay: 2000
}).as('getStudentTabDetails');
})
})
Then('I am logged in as the student user', () => {
cy.get('[name=loginUsername]').type("Student1");
cy.get('[name=loginPassword]').type("somePassword1", { sensitive: true });
cy.contains('Login').click();
})
Then('I click on {string} subtab', (student) => {
cy.get('#main a').contains(student).click({force:true});
});
Then('I should see details displayed', () => {
cy.wait('@getStudentTabDetails', { timeout: 5000 });
});
Error:
CypressError 超时重试:cy.wait() 超时等待 5000 毫秒以等待对路由的第一个请求:getStudentTabDetails。从未发生过请求。